How would shallow generators compose with lambda?

Mark S. Miller erights at
Thu May 14 10:25:06 PDT 2009

Two features that have been proposed for Harmony are shallow
generators and lambda.

In the absence of lambda, I think I understand shallow generators.
Because of the way my brain is wired, for whatever reason, my path to
understanding them is as a source-to-source cps-style transform of the
generator function -- the function immediately containing the 'yield'.
Because generators are shallow, only this function need be translated.
I do understand that other people find this route to understanding
shallow generators unnatural.

In the absence of generators, I am confident I understand lambda. A
return in a lambda returns from the immediately containing function
activation, so long as that function activation is still active. If
the containing function has already returned, then a postponed attempt
to return from it again will fail[1], presumably with a thrown error.
This applies as well to break, continue, labeled break, labeled
continue, and labeled return if we introduce such a thing. What
happens to a postponed 'yield'? Also, does it make as much sense to
introduce a labeled yield as it does to introduce a labeled return?

Given both shallow generators and lambda, I don't understand how they
would interact.

[1] Schemers would say "dynamic extent continuations" vs Scheme's
"indefinite extent continuations". Indefinite extent continuations --
which can be returned from multiple times -- are IMO a horror.
Indefinite extent continuations would enable deep generators, which
only increases my sense of horror. Perhaps combining lambda with
shallow generators produces something like delimited continuations?
The literature on these makes my brain hurt.


More information about the es-discuss mailing list