Fantastic, thanks for the clarification Ben. I'll start using it to see
what it does, as I have a few functions that occasionally throw errors
through contracts - which I should call 'blame' - yet I can't figure out
much from it.

On Fri, Apr 17, 2020 at 6:09 PM Ben Greenman <[email protected]>
wrote:

> 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 a topic in the
> Google Groups "Racket Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/racket-users/VA_ufNV6J24/unsubscribe.
> To unsubscribe from this group and all its topics, 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
> .
>

-- 
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/CAD7_NO7Yo%2BL-T5JnxKB74-OPNce3On0YY%3DujHLR7L%2B1Ch%2Bqz1w%40mail.gmail.com.

Reply via email to