Nick Krempel (2013-12-04T11:16:30.000Z)
Taking it further, a (probably controversial) suggestion would be to allow
"let" and "const" to be expressions, enabling:

```js
if ((let foo = getFoo()).isReady()) {
   // foo in scope
} else {
  // foo in scope
}
// foo not in scope
```

There would be some details about whether its value is a Reference and what
to do with "let a = 1, b = 2" but probably the biggest issue would be
parsing ambiguities?

Or in a different direction, could consider allowing ToBoolean conversions
for objects to be overloaded.

Even without either of the two additions proposed above, I would still find
the if/switch/while(let) construct useful. For example, often a value is
known to be either an object or null (or undefined). (And if it had the
value 0 due to a bug in my program, it's not clear whether I want the true
branch or the false branch anyway: so I should just use an assert if I want
to protect against this.)

Nick



On 4 December 2013 10:38, Andreas Rossberg <rossberg at google.com> wrote:

> On 4 December 2013 11:14, Brendan Eich <brendan at mozilla.com> wrote:
> > I took him to mean "please support const or let" - for sure! :-)
>
> To voice the con side, I'm not fond of binders in conditions because
> they depend on -- and thus encourage overuse of -- falsy/truthy values
> or other implicit-conversion-like techniques (and their metastasis in
> APIs). I have seen that harm overall clarity more than it helps, at
> least in C++.
>
> /Andreas
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131204/b03e7e9e/attachment-0001.html>
domenic at domenicdenicola.com (2013-12-10T01:45:12.664Z)
Taking it further, a (probably controversial) suggestion would be to allow
"let" and "const" to be expressions, enabling:

```js
if ((let foo = getFoo()).isReady()) {
   // foo in scope
} else {
  // foo in scope
}
// foo not in scope
```

There would be some details about whether its value is a Reference and what
to do with "let a = 1, b = 2" but probably the biggest issue would be
parsing ambiguities?

Or in a different direction, could consider allowing ToBoolean conversions
for objects to be overloaded.

Even without either of the two additions proposed above, I would still find
the if/switch/while(let) construct useful. For example, often a value is
known to be either an object or null (or undefined). (And if it had the
value 0 due to a bug in my program, it's not clear whether I want the true
branch or the false branch anyway: so I should just use an assert if I want
to protect against this.)