Nick Krempel (2013-11-29T16:29:48.000Z)
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131129/0fa36f57/attachment.html>
domenic at domenicdenicola.com (2013-12-10T01:40:16.383Z)
Couldn't find anything on this in the archives, but is there a proposal for:

```js
if (let var = expr) {
  // var in scope
}
else {
  // var in scope
}
// var out of scope
```

i.e. shorthand for:

```js
{
  let var = expr;
  if (var) {
    // ...
  }
  else {
    // ...
  }
}
```

Also:

```js
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".)