let/const in switch cases

Brendan Eich brendan at mozilla.org
Tue Aug 14 08:56:24 PDT 2012


Allen Wirfs-Brock wrote:
>  From a usability case we have to consider which is more likely something like the above or something like:
>
>       switch (x) {
>         case 0:
>             let a = ...;
>             // lots of lines of code using a
>             break;
>         case 1:
>              let b = ...;
>              // lots of lines of code using b
>              break;
>          case 2:
>              ...
>      }
>
> My guess was that the disjoint case would be more common and more annoying if it was disallowed.

Exactly!

Did anyone read the Mozilla JS at those DXR links I gave? :-P

>    I considered spec'ing each case alternative as a block but I concluded it would be unwise to introduce a block scope that was not associated with {  }'s.

No can do with fall-through.

/be


More information about the es-discuss mailing list