arrow syntax unnecessary and the idea that "function" is too long

Andrew Dupont mozilla at
Tue May 10 16:06:32 PDT 2011

To Oliver's point: I think this would qualify as bikeshedding if this didn't really matter. It is a tiny detail, but an important one, so it makes sense that we've spent so long discussing it.

I acknowledge the arrow notation's advantages over #:
(a) we've got precious few ASCII characters left and the octothorp has been claimed by several strawmen;
(b) the proposed octothorp syntax doesn't solve the ->/=> thing (having a concise syntax for binding functions to current scope);
(c) prior art of CoffeeScript.

I'm not completely sold on it, though, for a couple of reasons:
(a) the "cost" of typing an arrow on a western keyboard is much higher than the cost of an octothorp;
(b) the ->/=> distinction is, I think, too subtle. Rebinding dramatically changes the meaning of the function, so I'd prefer if the notation guaranteed that a user couldn't gloss over that by mistaking -> for => or vice/versa.

To rephrase that second point: I think it's a good idea to have a shorthand syntax for `.bind(this)`, but it has to make itself more obvious than the arrow notation proposes. And there's nothing precluding a similar syntax for the octothorp (e.g., `#(x){ }` vs. `##(x){ }` — retaining Brendan's point that the rebinding syntax should be "fatter").

(Also, for the purposes of this argument, I'm fine with using another of our free ASCII characters in place of the octothorp.)


On May 10, 2011, at 5:42 PM, Breton Slivka wrote:

> I have to say that I was a bit indifferent about the different
> syntaxes on offer until I had a good look at the strawman, and found
> that there were differences between -> => and #(x)->(x*x); with
> regards to |this| binding. I have to admit that at the moment, exactly
> what those subtleties are, is a little over my head at the moment.
> But given I have to explain |this| again
> and again
> and again...
> I appreciate efforts to address the |this| problem. I think though,
> that in terms of familiarity, "bind" already effectively solves that
> specific issue. The  # operator seems too much like ambient magic to
> me.
> Broadly, I like how the arrow syntax resembles mathematical notation
> for "functional dependency", much like the original function syntax
> resembles mathematical notation for "function". Given some time, I
> don't think it would be hard to get used to. But it might scare some
> programmers easily spooked by "weird" syntax.  We're the experts, the
> language designers (you), and the advanced users (me and others), who
> are drawn to and appreciate javascript due to its resemblance to
> scheme and haskell etc. etc. so the arrow syntax appeals to us on that
> level. But one of the strengths of Javascript has been as a
> syntactical trojan horse- Getting these nice qualities under the noses
> of people who would otherwise find that stuff unpalatable. For this
> reason, as much as I like arrow syntax, and attempts to address |this|
> scoping, I have to lean towards #(x){x*x}, and us syntactical snobs
> can still have coffeescript.
> I still wish there was a way to make |this| less confusing though. I'm
> sure you do too.
> -Breton
> _______________________________________________
> es-discuss mailing list
> es-discuss at

More information about the es-discuss mailing list