Re: if-scoped let

2013-12-06 Thread John Lenz
Nm. It would be illegal in the current spec. On Dec 6, 2013 7:07 PM, "John Lenz" wrote: > Wouldn't waiting for es7 make this a breaking change? > On Dec 3, 2013 4:46 PM, "Brendan Eich" wrote: > >> I mailed Arv and he kindly offered to draft and champion a bite-sized >> strawman for ES7, to suppo

Re: if-scoped let

2013-12-06 Thread John Lenz
Wouldn't waiting for es7 make this a breaking change? On Dec 3, 2013 4:46 PM, "Brendan Eich" 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 >> Decemb

Re: if-scoped let

2013-12-04 Thread Brendan Eich
Yup. This is way, Way lower priority than if(let|const). /be > On Dec 4, 2013, at 10:26 PM, Sean Silva wrote: > > > > >> On Tue, Dec 3, 2013 at 9:13 PM, Waldemar Horwat wrote: >>> On 12/03/2013 05:30 PM, Mark S. Miller wrote: >>> What's ^^ ? >> >> a^^b would essentially be the same as !a!=

Re: if-scoped let

2013-12-04 Thread Sean Silva
On Tue, Dec 3, 2013 at 9:13 PM, Waldemar Horwat wrote: > On 12/03/2013 05:30 PM, Mark S. Miller wrote: > >> What's ^^ ? >> > > a^^b would essentially be the same as !a!=!b except that it would return > the actual truthy value if it returns true. Those semantics are extremely error-prone. `(("fo

Re: if-scoped let

2013-12-04 Thread Olov Lassus
2013/12/4 Andreas Rossberg > I don't understand. Why can't you do > > const val = compute(something) > if (val) { > // ... > } > (also Axel) Oops - yeah I sure could. consts are one honking great idea -- let's do more of those! That's all. :) /Olov __

Re: if-scoped let

2013-12-04 Thread Brendan Eich
Nick Krempel wrote: I should also say that I agree with you that it is unfortunate that if getFoo() is a function returning either a number or undefined (say), you can't use the proposed if(let) syntax to distinguish undefined. Then you would have to write it out the long way, and use a block

Re: if-scoped let

2013-12-04 Thread Brendan Eich
Nick Krempel wrote: 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 wh

Re: if-scoped let

2013-12-04 Thread Nick Krempel
I should also say that I agree with you that it is unfortunate that if getFoo() is a function returning either a number or undefined (say), you can't use the proposed if(let) syntax to distinguish undefined. On 4 December 2013 11:16, Nick Krempel wrote: > Taking it further, a (probably controv

Re: if-scoped let

2013-12-04 Thread Nick Krempel
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 Re

Re: if-scoped let

2013-12-04 Thread Andreas Rossberg
On 4 December 2013 11:14, Brendan Eich 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

Re: if-scoped let

2013-12-04 Thread Brendan Eich
I took him to mean "please support const or let" - for sure! :-) /be > On Dec 4, 2013, at 11:09 AM, Andreas Rossberg wrote: > >> On 4 December 2013 11:03, Brendan Eich wrote: >> Olov did write "because val leaks to the outer scope". That's a reason for >> the convenience of >> >> if (let x =

Re: if-scoped let

2013-12-04 Thread Andreas Rossberg
On 4 December 2013 11:03, Brendan Eich wrote: > Olov did write "because val leaks to the outer scope". That's a reason for > the convenience of > > if (let x = ...) { /* x in scope here */ } > > (or const), vs. > > { let x = ...; if (x) { /* ... */ } } > > Braces count, this is winning in C++. Ye

Re: if-scoped let

2013-12-04 Thread Brendan Eich
Olov did write "because val leaks to the outer scope". That's a reason for the convenience of if (let x = ...) { /* x in scope here */ } (or const), vs. { let x = ...; if (x) { /* ... */ } } Braces count, this is winning in C++. /be ___ es-discuss

Re: if-scoped let

2013-12-04 Thread Andreas Rossberg
On 4 December 2013 10:13, Olov Lassus wrote: > I wanted to do > > if (const val = compute(something)) { > // ... > } > > but I had to do > > let val; > if (val = compute(something)) { > // ... > } > > which is unfortunate not only because val leaks to the outer scope but also > because let

Re: if-scoped let

2013-12-04 Thread Axel Rauschmayer
On 04 Dec 2013, at 9:13 , Olov Lassus wrote: > I wanted to do > > if (const val = compute(something)) { > // ... > } > > but I had to do > > let val; > if (val = compute(something)) { > // ... > } > > which is unfortunate not only because val leaks to the outer scope but also > beca

Re: if-scoped let

2013-12-04 Thread Olov Lassus
2013/11/29 Nick Krempel > Couldn't find anything on this in the archives, but is there a proposal > for: > > if (let var = expr) { > // var in scope > } > ... > ("const" should also be OK in place of "let", at least for "if" and > "switch".) > Thanks for taking this to the list. I was meaning

Re: if-scoped let

2013-12-03 Thread Brendan Eich
Waldemar Horwat wrote: a^^b would essentially be the same as !a!=!b except that it would return the actual truthy value if it returns true. I have to say if (let x = ... ) { /* that x in scope here */ } is >>> ^^, if you get what I mean :-P. /be __

Re: if-scoped let

2013-12-03 Thread Waldemar Horwat
On 12/03/2013 05:30 PM, Mark S. Miller wrote: What's ^^ ? a^^b would essentially be the same as !a!=!b except that it would return the actual truthy value if it returns true. Waldemar ___ es-discuss mailing list es-discuss@mozilla.org https://m

Re: if-scoped let

2013-12-03 Thread Mark S. Miller
What's ^^ ? On Tue, Dec 3, 2013 at 4:46 PM, Brendan Eich 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 >> December 3, 2013 2:55 AM >> >> >> >> I f

Re: if-scoped let

2013-12-03 Thread Brendan Eich
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 December 3, 2013 2:55 AM I frequently use the C++ equivalent of this. Haven't proposed it as part of the scoping up

Re: if-scoped let

2013-12-02 Thread Waldemar Horwat
On 11/29/2013 08:29 AM, Nick Krempel wrote: 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 frequently use the C++ equivalent of this. Haven't proposed it as part of the

Re: if-scoped let

2013-11-29 Thread Erik Arvidsson
I also miss these from C++, especially the if form. I also agree that we do not want the do-while form of this. On Fri, Nov 29, 2013 at 1:49 PM, Brendan Eich wrote: > Nick Krempel wrote: >> >> Slight correction: bring in line with "for in" and "for of" only - since >> the condition part of the "

Re: if-scoped let

2013-11-29 Thread Brendan Eich
Nick Krempel wrote: Slight correction: bring in line with "for in" and "for of" only - since the condition part of the "for" does not allow this currently. Right, and for (let...;;) has (consensus reconfirmed last meeting) a fresh let binding per iteration (and one for the pre-loop scope if t

Re: if-scoped let

2013-11-29 Thread Nick Krempel
Slight correction: bring in line with "for in" and "for of" only - since the condition part of the "for" does not allow this currently. On 29 November 2013 16:29, Nick Krempel wrote: > Couldn't find anything on this in the archives, but is there a proposal > for: > > if (let var = expr) { >

if-scoped let

2013-11-29 Thread Nick Krempel
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) {