[plt-scheme] inheriting dynamic extent

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Apr 1 22:46:28 EST 2005

On Apr 1, 2005, at 9:17 PM, Doug Orleans wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> The dynamic extent of a procedure is the time when processing is
> "inside" a procedure, but it doesn't include the dynamic extent of
> procedures created during this time.  For example:
>
> ((let ((x 1))
>    (dynamic-wind (lambda () (set! x 2))
>                  (lambda () (lambda () x))
>                  (lambda () (set! x 1)))))
> ; => 1
>
> Or equivalently:
>
> ((let ((x 1))
>    (fluid-let ((x 2))
>      (lambda () x))))
> ; => 1
>
> Is there some way to allow procedures to "inherit" dynamic extent?
> (Or some trick to simulate this?)  In other words, is there a way to
> make something analogous to this example that returns 2 instead of 1?

I believe you want to "close" your value with the current state:

  {(let ((x 1))
     (fluid-let ((x 2))
       (close (lambda () x)))}

In my mind, (close e) = (let ((a a) ...) e) for all a in fv(e)

Would this give you what you really want? -- Matthias



Posted on the users mailing list.