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