[racket-dev] RFC: "provide" via mutation

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Jun 21 15:29:42 EDT 2010

Can you explain why this works? -- Matthias



On Jun 21, 2010, at 3:15 PM, Sam Tobin-Hochstadt wrote:

> The following program implicitly does something like `provide', via mutation.
> 
> #lang racket/load
> 
> (module store racket
>  (define s (box #f))
>  (provide s))
> 
> (module m typed/racket
>  (require (for-syntax 'store))
>  (define: (x) : Number 1)
>  (begin-for-syntax (set-box! s #'x)))
> 
> (module n typed/racket
>  (require (for-syntax 'store) 'm)
>  (define-syntax (mac stx)
>    (define myx (unbox s))
>    #`(add1 (#,myx)))
>  (mac))
> 
> (require 'n)
> 
> The certificate system currently allows this, although it's not
> obvious to me that it should.  Typed Scheme also ensures that it
> typechecks.  However, Typed Scheme could save a bunch of work at
> startup if this didn't have to typecheck.  What do people think is the
> right tradeoff?  Does anyone care about programs like this?  Should
> the certificate system allow them?  Should Typed Scheme make them
> work, at the cost of some performance?
> -- 
> sam th
> samth at ccs.neu.edu
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/dev



Posted on the dev mailing list.