> When I want to enable these private contracts (e.g. when running tests or
> debugging a problem) I simply change the source code of `def/c` so that it
> is wired up to `define/contract` and the contract is checked. Here is an
> example: http://pasterack.org/pastes/4224

You can run arbitrary code in macros so you could use environment
variables to achieve this.  For example:

    (define-syntax-rule (def/c head contract body ...)
      (if (getenv "PRIVATE_CONTRACTS")
        (define/contract head contract body ...)
        (define head body ...)))

And then run your code with

    env PRIVATE_CONTRACTS=x racket some-module.rkt

The drawbacks to this approach is it makes compilation significantly
slower and, once code is compiled (via raco setup, raco make or raco pkg
install), the flag stops having any effect -- the code is compiled
according to whatever the environment looks like at compile time and
then maintains that behavior until it is recompiled.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/m2r26gk9oa.fsf%40192.168.0.139.

Reply via email to