Lambda vs. function
brendan at mozilla.com
Mon Oct 27 09:49:50 PDT 2008
On Oct 27, 2008, at 8:21 AM, Maciej Stachowiak wrote:
>> A more functional multiple-case dispatch form would be like
>> Scheme's `cond' or ML/Haskell `case'. God, we need macros.
> ECMAScript's switch is sort of halfway between Scheme cond and C
> switch. Personally I think fall through and explicit break were
> unnecessary concessions to C-likeness but I don't think they create
> insurmountable problems. Case labels at arbitrary points in the code
> would be much worse because it's hard to describe them in any way
> but a controlled goto.
Netscape management said that JS had to "look like Java", which
follows C in having fall-through from an upper case to a lower one.
Same as C++. That's a big head-wind to tack against, and I was not
prepared to explain yet another switch statement to Java-heads circa
As you say, at least we don't have the C/C++ arbitrary case label in
switch body fun. Useful for low-level hacking a la Duff's Device, but
hazardous scaled over a large distribution of programmer ability
(IIRC, comp.risks had an item on an AT&T telephony switch crash in the
late '80s or early '90s that was blamed on a missing break. I can't
find it atm via Google search, which makes me sad; anyone with a
pointer, please mail me).
FWIW, I agree switch can have tail position calls in its cases. That
it is messy to specify, that fall-through makes it irregular, doesn't
seem like enough of a reason to specify no tail call positions in
More information about the Es-discuss