[plt-scheme] Re: expansion continuations and barriers
Ryan Culpepper wrote:
> 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.
By this line of reasoning, I would think you're arguing that the
expander is broken (like the almost-implementation of map), not the code
that uses let/cc.
I am trying to implement a library for writing macros in monadic style,
similar in spirit to SRFI 53. The implementation technique there is to
translate everything into CPS "under the hood". Is this the only
feasible technique for this kind of thing?
Thanks again,
David