Nm. It would be illegal in the current spec. On Dec 6, 2013 7:07 PM, "John Lenz" <[email protected]> wrote:
> Wouldn't waiting for es7 make this a breaking change? > On Dec 3, 2013 4:46 PM, "Brendan Eich" <[email protected]> wrote: > >> I mailed Arv and he kindly offered to draft and champion a bite-sized >> strawman for ES7, to support if/while/switch(let). Yay! >> >> /be >> >> Waldemar Horwat <mailto:[email protected]> >>> December 3, 2013 2:55 AM >>> >>> >>> I frequently use the C++ equivalent of this. Haven't proposed it as >>> part of the scoping upgrades just to keep things small, but I don't have >>> any good reason not to do something like this either. It kind of falls in >>> the same bucket as &&=, ||=, and ^^. >>> >>> Waldemar >>> >>> _______________________________________________ >>> es-discuss mailing list >>> [email protected] >>> https://mail.mozilla.org/listinfo/es-discuss >>> >>> Nick Krempel <mailto:[email protected]> >>> November 29, 2013 5:29 PM >>> Couldn't find anything on this in the archives, but is there a proposal >>> for: >>> >>> if (let var = expr) { >>> // var in scope >>> } >>> else { >>> // var in scope >>> } >>> // var out of scope >>> >>> i.e. shorthand for: >>> >>> { >>> let var = expr; >>> if (var) { >>> // ... >>> } >>> else { >>> // ... >>> } >>> } >>> >>> Also: >>> >>> switch (let var = expr) { >>> case foo: >>> // var in scope >>> default: >>> // var in scope >>> } >>> // var out of scope >>> >>> ...which has a similar expansion. >>> >>> Similarly for "while" and "do...while": this would bring everything in >>> line with the current "for" / "for in" / "for of". >>> >>> This also matches what C++ allows, with the exception of "do...while" >>> (in our case, it seems acceptable to allow "do...while" too - the value >>> would simply be "undefined" on the first iteration). >>> >>> ("const" should also be OK in place of "let", at least for "if" and >>> "switch".) >>> >>> Nick >>> >>> _______________________________________________ >>> es-discuss mailing list >>> [email protected] >>> https://mail.mozilla.org/listinfo/es-discuss >>> >> _______________________________________________ >> es-discuss mailing list >> [email protected] >> https://mail.mozilla.org/listinfo/es-discuss >> >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

