Re: Another switch

2014-02-21 Thread Nick Krempel
Also only works when you're switching on something with a meaningful conversion to string. On 21 February 2014 07:03, Mathias Bynens mathi...@opera.com wrote: On 20 Feb 2014, at 21:20, Eric Elliott e...@ericleads.com wrote: Object literals are already a great alternative to switch in JS:

Re: Another switch

2014-02-21 Thread Rick Waldron
On Fri, Feb 21, 2014 at 7:55 AM, Nick Krempel ndkrem...@google.com wrote: Also only works when you're switching on something with a meaningful conversion to string. On 20 Feb 2014, at 21:20, Eric Elliott e...@ericleads.com wrote: Object literals are already a great alternative to switch in

Re: Another switch

2014-02-21 Thread Eric Elliott
In practice, I find that everything converts nicely to a string when you precede it with a ternary assignment. I also find that when you do that, it's pretty trivial to control what those strings are, which makes `hasOwnProperty` superfluous. I haven't used a switch in JavaScript for quite a few

Re: Another switch

2014-02-21 Thread C. Scott Ananian
In the ES6 world, you should probably set up a Map for your switch statement; that would allow you to easily use non-string cases. --scott ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Another switch

2014-02-20 Thread Eric Elliott
- From: Brendan Eich Sent: Wednesday, February 12, 2014 2:00 AM To: Nathan Wall Cc: Giacomo Cau ; es-discuss@mozilla.org Subject: Re: Another switch Definitely good to see new languages being designed and implemented. JS is not going to break compatibility on the old fall-through behavior

Re: Another switch

2014-02-20 Thread Mathias Bynens
On 20 Feb 2014, at 21:20, Eric Elliott e...@ericleads.com wrote: Object literals are already a great alternative to switch in JS: var cases = { val1: function () {}, val2: function () {} }; cases[val](); In that case, you’d need a `hasOwnProperty` check to make sure you’re not

Re: Another switch

2014-02-17 Thread Giacomo Cau
-Messaggio originale- From: Brendan Eich Sent: Wednesday, February 12, 2014 2:00 AM To: Nathan Wall Cc: Giacomo Cau ; es-discuss@mozilla.org Subject: Re: Another switch Definitely good to see new languages being designed and implemented. JS is not going to break compatibility

RE: Another switch

2014-02-11 Thread Nathan Wall
Perhaps you will at least find it interesting. :) Nathan From: cau.giacomo...@tiscali.it To: es-discuss@mozilla.org Subject: Another switch Date: Sun, 9 Feb 2014 10:41:40 +0100 Hello to all I wish to submit a little proposal. Today the switch

Re: Another switch

2014-02-11 Thread Brendan Eich
Definitely good to see new languages being designed and implemented. JS is not going to break compatibility on the old fall-through behavior of switch, inherited from Java from C++ from C. All the C-like languages copy this flaw, because to do otherwise with the same keyword would be worse

Re: Another switch

2014-02-11 Thread Claude Pache
: Another switch Date: Sun, 9 Feb 2014 10:41:40 +0100 Hello to all I wish to submit a little proposal. Today the switch statement has an explicit break at the end of the statement and an implicit continue to the next case but this break is very boring and error prone. Wouldn’t

Another switch

2014-02-09 Thread Giacomo Cau
Hello to all I wish to submit a little proposal. Today the switch statement has an explicit break at the end of the statement and an implicit continue to the next case but this break is very boring and error prone. Wouldn’t it be possible to think a switch that has an explicit

RE: Subject: Another switch

2014-02-09 Thread Benjamin (Inglor) Gruenbaum
I'm new too, but don't think that's exactly how things get proposed here :) Spec changes don't start with solutions - they start with existing problems you're trying to solve. For example. In ES6 I might do ```js var res = ({ hello : () = 12, /* no fallback */ world : () = 323, /* no