On 4/17/20, Sorawee Porncharoenwase <[email protected]> wrote: >> >> My understanding is that contract-out only provides protection against >> inappropriate calls from clients *outside* the module, whereas >> define/contract enforces the contract against everyone, including things >> inside the module. Do I have that right? >> > > I think that's correct. Note though that the implication is that > define/contract could produce a much more expensive code, especially for > recursive function, since it will need to check against the contract for > every iteration. > > >> On a related topic, I don't understand the concept of positive and >> negative blame. Can someone fill me in? >> > > I always forget which is positive and negative, so I won't use the terms > here (and too lazy to lookup). But roughly, suppose you attach a function > contract (-> number? string?) to a function value, then there are mainly > two ways things could go wrong. > > 1. Client uses the function incorrectly by calling it with non-number. > 2. The function itself returns a non-string. > > A blame would indicate whose party is at fault when a contract is > violated--caller or the function itself.
1 = negative = the client that uses the value 2 = positive = the code that made the value But unless you're using `contract` directly, you don't need to know these words to benefit from contracts. -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAFUu9R5vabY64_HZRWv1zNoyuEd7K5p8i8jfVN0JB1reufYEPw%40mail.gmail.com.

