return when desugaring to closures

David-Sarah Hopwood david.hopwood at
Thu Sep 4 10:57:14 PDT 2008

Mark S. Miller wrote:
> On Mon, Aug 25, 2008 at 7:24 PM, Dave Herman <dherman at> wrote:
>>> But I'd still rather not try to understand generators
>>> by CPS-transforming the relevant bits of the RI.
>> A little confused here-- was that an errant "not"?
> No. I meant that, since I understand continuation by CPS-transform, if
> the RI and/or the spec explains generators by absorbing them into
> SML's delimited continuations, then I'd need try to understand
> generators by CPS-transforming that portion of the RI's
> implementation. Given a choice between understanding generators that
> way vs. understanding them by CPS transforming the ES generator code,
> the latter seems preferable. Again, this may just be a personal
> idiosyncrasy.

It's not just your personal idiosyncrasy. I also find it almost impossible
to understand the effects of (even delimited) continuations directly.
The semantics of CPS-transformed code is straightforward, no matter how
ugly the code may be.

Dave Herman <dherman at> wrote:
 > Mark S. Miller wrote:
>> I didn't know SML has delimited continuations.
> It doesn't officially; SML/NJ and MLton implement callcc, which you can 
> use to implement shift and reset. So it's admittedly on the edge of ML's 
> semantics. But these are all very well-understood control operators and 
> easy to add to the formal semantics of SML.

Hmm. I thought the motivation for using SML is that it had a definite
formal semantics (for which the last revision was published a decade ago),
that had already been looked at and understood by many people.
Handwaving about the possibility of adding delimited continuations to
that formalization is not the same thing, even if you are right in
saying it is "easy".

David-Sarah Hopwood

More information about the Es-discuss mailing list