That's the best solution I've come up with, which is basically the abstraction I suggested under #4.<div><br></div><div>sam th<br><br>On Sunday, September 25, 2011, Carl Eastlund wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
How about we write a "define-toggle-contract-out" form, so everyone<br>
can define their own without actually implementing their own.<br>
Something like so:<br>
<br>
(define-toggle-contract-out my-contract-out #:disable) ;; comment out<br>
keyword to enable<br>
(provide (my-contract-out [thing thing/c]))<br>
<br>
Carl Eastlund<br>
<br>
On Sun, Sep 25, 2011 at 7:41 PM, J. Ian Johnson <<a>ianj@ccs.neu.edu</a>> wrote:<br>
> Everyone rolling their own is bad. We want people to contract their code, and they don't want to always pay for the overhead. #2 sounds the best, since that could be again abstracted over by the user, this time with one line instead of the sevel it takes to implement provide-cond-contract. This also has the advantage that the user can have access to any subforms someone else adds later.<br>
> -Ian<br>
> ----- Original Message -----<br>
> From: Sam Tobin-Hochstadt <<a>samth@ccs.neu.edu</a>><br>
> To: J. Ian Johnson <<a>ianj@ccs.neu.edu</a>><br>
> Cc: Matthew Flatt <<a>mflatt@cs.utah.edu</a>>, <a>dev@racket-lang.org</a><br>
> Sent: Sun, 25 Sep 2011 11:34:39 -0400 (EDT)<br>
> Subject: Re: [racket-dev] contract-out<br>
><br>
> On Sun, Sep 25, 2011 at 10:55 AM, J. Ian Johnson <<a>ianj@ccs.neu.edu</a>> wrote:<br>
>> Very nice! Is it easy to make a provide form that conditionally provides with contracts, such as Sam's provide-cond-contract in typed-scheme/utils/utils.rkt?<br>
><br>
> The trouble with this is that it's not clear how it should be<br>
> controlled. There are a few obvious possibilities:<br>
><br>
> 1. There's a global flag for all of Racket which turns contracts on<br>
> and off. It should be pretty clear that this is a bad idea.<br>
> 2. There's a form like `(contract-cond-out expr stuff ...)' which<br>
> uses the contracts in `stuff' IFF `expr' is true. This is easy to<br>
> implement, but pretty inconvenient to use.<br>
> 3. Something like the status quo, where everyone defines their own<br>
> thing, but maybe with some abstraction.<br>
> 4. A compiler flag. We don't have anything like this, though,<br>
> currently, and it's not clear how it should work.<br>
><br>
><br>
>> -Ian<br>
>> ----- Original Message -----<br>
>> From: Matthew Flatt <<a>mflatt@cs.utah.edu</a>><br>
>> To: <a>dev@racket-lang.org</a><br>
>> Sent: Sat, 24 Sep 2011 09:41:17 -0400 (EDT)<br>
>> Subject: [racket-dev] contract-out<br>
>><br>
>> The `racket/contract' and `racket' modules now provide `contract-out',<br>
>> which is a `provide' form for contracts. Use<br>
>><br>
>> (provide (contract-out ....))<br>
>><br>
>> instead of<br>
>><br>
>> (provide/contract ....)<br>
>><br>
>><br>
>> There's one difference between `(provide (contract-out ....))' and<br>
>> `(provide/contract ....)': contract expressions in contract-out' are<br>
>> implicitly moved to the end of the module, which means that they can<br>
>> refer to variables that are defined later. For example, the following<br>
>> program works as you'd expect:<br>
>><br>
>> #lang racket<br>
>><br>
>> (provide (contract-out [mask-of (turtle? . -> . color?)])<br>
>> turtle?<br>
>> color?)<br>
>><br>
>> (define (turtle? v)<br>
>> (memq v '(Leonardo Michelangelo Donatello Raphael)))<br>
>> (define (color? v)<br>
>> (memq v '(blue orange purple red)))<br>
>><br>
>> (define (mask-of t)<br>
>> (match t<br>
>> ['Leonardo 'blue]<br>
>> ['Michelangelo 'orange]<br>
>> ['Donatello 'purple]<br>
>> ['Raphael 'red]))<br>
>><br>
>><br>
>> The `contract-out' form is implemented as a provide pre-transformer,<br>
>> which is a new kind of `provide' form that is now supported by<br>
>> `racket/provide-transform'.<br>
>><br>
>> _________________________________________________<br>
>> For list-related administrative tasks:<br>
>> <a href="http://lists.racket-lang.org/listinfo/dev" target="_blank">http://lists.racket-lang.org/listinfo/dev</a><br>
>><br>
>> _________________________________________________<br>
>> For list-related administrative tasks:<br>
>> <a href="http://lists.racket-lang.org/listinfo/dev" target="_blank"></a></blockquote></div><br><br>-- <br>sam th<br><a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a><br>