I think the answer here really is “don’t use `contract` directly”. The
actual implementation of the contract system does some fancy rebinding
of my-func when you use define/contract, turning this:

   (define/contract x ctc rhs)

into this:

   (define x-awaiting-neg
     (let ([tmp rhs])
       (lambda (neg) (contract ctc tmp 'x neg))))

So specifying the negative party is deferred. It then defines an
additional syntax binding that supplies the negative party based on the
use site of x, which works like something along these lines:

   (define-syntax x
     (make-variable-like-transformer
       #'(x-awaiting-neg (quote-module-name))))

where `quote-module-name` comes from syntax/location.

This isn’t 100% accurate to what the contract system actually does, but
the gist is that the negative party represents the client, so somehow
you need to arrange for a different value to be supplied depending on
what the client party actually is.

Getting this right is tricky, so stick to contract-out, define/contract,
with-contract, and define-struct/contract, which are the sanctioned
contract attachment forms. For macros, there’s also `expr/c` syntax
class from syntax/parse and the equivalent `wrap-expr/c` function from
syntax/contract. Those will work out the tricky machinery for you behind
the scenes, and they usually cover all the potential use cases. If you
have some other use case that isn’t served by those contract attachment
forms, by all means share it, but it’s hard to advise how to use
`contract` properly in a vacuum.

> On Sep 10, 2018, at 12:40, David Storrs <david.sto...@gmail.com> wrote:
> 
> (define (my-func thunk-arg)
>     (contract  integer? (thunk-arg) 'my-func <CALLER>))
> 
> What should I replace <CALLER> with?
> 
> 
> NB: I know that in the example I could do 
>     (define/contract (my-func thunk-arg) (-> (-> integer?) integer?) 
> (thunk-arg))
> but I'm looking for an answer to the generic case.

-- 
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.

Reply via email to