[racket-dev] contract-out

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Sun Sep 25 21:40:23 EDT 2011

On Sun, Sep 25, 2011 at 9:36 PM, Eli Barzilay <eli at barzilay.org> wrote:
> 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))]))

But now I have to change all the places that use these identifiers.
The "turn on and off internal contracts" and "give me unchecked access
to this library" use cases are genuinely different.
-- 
sam th
samth at ccs.neu.edu



Posted on the dev mailing list.