One more clarification :p Contracts are always checked at run-time. Each time you call a function with a contract on it, you need to check the contract.
Typed functions called from typed code are checked at compile-time. They're both safe and fast at run-time. The tricky part is when typed and untyped code interacts i.e. you call a typed function from an untyped script. When that happens, Typed Racket compiles types into contracts and checks those at run-time. On Mon, Feb 29, 2016 at 4:41 PM, Asumu Takikawa <as...@ccs.neu.edu> wrote: > On 2016-02-29 11:01:17 -0800, Nota Poin wrote: > > I'm not sure what the qualitative distinction is between contracts and > Typed > > Racket. They seem like two syntaxes for what mostly amount to the same > thing. > > > > [...] > > > > Is it that contracts are more general, not always necessarily contracts > of > > functions that operate on types? > > Contracts are indeed more general. You can write arbitrarily complex > checks in > contracts, like that the given input-port is not closed, or that the number > that was inputted is a power of 2. > > You can't express these properties in Typed Racket's types. > > The idea is that a Racket programmer will start hardening their program by > writing contracts, possibly ones that are stronger checks than types. > > Eventually that programmer may want to add types to detect violations > earlier > or within a module, and may remove some of those manually-written > contracts. > Ideally you could add types *and* keep the contracts you wrote that are > more > expressive than the types. > > (we don't have that last step yet, but we should in the future) > > Cheers, > Asumu > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.