> What about for-in loops?
>
> I'm proceeding from user expectations being confounded. Something  
> needs help here, possibly not for (;;) loops -- but almost certainly  
> for-in loops containing closures capturing the loop variable.

Whatever is done should be consistent between for and for-in.  My  
concern was that you were suggesting that a closure over *any* let  
variable binds the value and not the scope.  i.e.:

   let x = 5;
   let f = function() {
     print(x);
   }
   x = 6;
   f(); // prints 5??

I don't think that's what you were proposing, but I wasn't entirely  
clear.

> So we can have our cake and eat it too with a tail-recursive  
> desugaring that forwards the previous iteration's binding value to  
> the next iteration's binding. Of course any practical implementation  
> will have to do more analysis than is currently done in the top open- 
> source implementations I've looked at. Could be worth the cost (VM  
> hackers can take the cost for the larger team of users). What do you  
> think?

Yeah, I got lost in the thread and missed the subtlety of that follow- 
up.  I'm having a hard time seeing any downside, other than perhaps a  
mild inconsistency between var and let behavior here.  Worth it, just  
as long as any form with the general syntax of

   <keyword> ( ... <let declaration/assigment> ... ) { <body> }

behaves in the same manner. (My point being that it's syntactically  
strange that let appearing outside of the braces is bound inside the  
braces --thinking like a language user, not a language implementer --  
but that's good behavior as long as it's consistent.)

_______________________________________________
Es-discuss mailing list
Es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to