return when desugaring to closures

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


On Mon, Oct 13, 2008 at 9:13 AM, Jon Zeppieri <jaz at bu.edu> 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?


yes.


> 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

   Cheers,
   --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.mozilla.org/pipermail/es-discuss/attachments/20081013/61367293/attachment.html 


More information about the Es-discuss mailing list