[plt-scheme] Re: expansion continuations and barriers

From: Ryan Culpepper (ryanc at ccs.neu.edu)
Date: Tue Jul 24 17:13:28 EDT 2007

On Tue, 2007-07-24 at 16:13 -0400, David Van Horn wrote:
> Matthias Felleisen wrote:
> > It's an effect.
> But so is module-identifier-mapping-put!; I don't see why there can't be 
> control effects at expansion time.  Can you elaborate?  Where would my 
> code go wrong if the continuation barrier weren't in place?

Control effects often interact badly with mutation. For example, a
popular almost-implementation of 'map' is to iterate through the list,
accumulate the result list in reverse order, and 'reverse!' it at the
end. Unfortunately, if one of the calls to the argument procedure
captures a continuation, and if the program later invokes that
continuation, then parts of the result list will be 'reverse!'d twice,
and you'll get a garbled result.

I expect that allowing full continuations during expansion would garble
the mutable data structures used to implement recursive scopes. You
could write a macro that defined a name but also defined a companion
macro that you could invoke to "take back" the definition.


Posted on the users mailing list.