[racket-dev] contract-out

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Sep 25 21:36:22 EDT 2011

An hour and a half ago, Sam Tobin-Hochstadt wrote:
> On Sun, Sep 25, 2011 at 8:14 PM, Eli Barzilay <eli at barzilay.org> wrote:
> > IMO, a better approach for disabling contracts is to have the
> > client decide whether it wants the contracted version or the plain
> > one -- which is a rough mirror of how unsafe operations are done
> > (with the choice being made by requiring one file or
> > another).  Then, there could be a facility that associates a safe
> > identifier with an unsafe version, so you could write (unsafe foo)
> > -- which will be the unsafe operation for builtins that have one,
> > and in case of a contracted function it will be the uncontracted
> > one.
> This wouldn't work for the Typed Racket use case, where I want to flip
> one switch for contracts throughout the TR code base.

(define-for-syntax contracts-on? #t)

(define-syntax (switch stx)
  (syntax-case stx ()
    [(_ id) (if contracts-on? #'id #'(unsafe id))]))

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.