return when desugaring to closures

Mark Miller erights at
Mon Oct 13 09:47:11 PDT 2008

On Mon, Oct 13, 2008 at 9:13 AM, Jon Zeppieri <jaz at> wrote:

> I like your intention here -- I brought up the iteration variable /
> closure issue earlier in the thread -- but this seems rather messy.
> In the 'var' case, x must be the same throughout, no?


> function foo() {
>  for (var x = ... ) { ... x ... }
>  ... x ...
> }
> But then it becomes extremely awkward for the 'let' or 'const' case to
> use a fresh variable on every iteration.  It ties the semantics of
> 'for' to its initialization clause in a very strange way.

I think it falls out of the natural desugaring of for to lambda with no
special cases. The "var" itself causes its own hoisting and joining.

Text by me above is hereby placed in the public domain

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Es-discuss mailing list