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

Brendan Eich brendan at mozilla.com
Mon May 9 18:55:51 PDT 2011


On May 9, 2011, at 2:21 AM, Irakli Gozalishvili wrote:
> On Monday, 2011-05-09 at 11:02 , Kyle Simpson wrote:
> 
>> Isn't that the spirit of what => would give us?
>> 
> Yes and this case makes following example extremely confusing:
> 
> MyObject.prototype.bar = #(x) { this.bar = x }
> 
> Is this instance of MyObject ? So we need to use `#` in some places, but in other cases we need to stick to long form `function`. I think `->` and `=>` is way more intuitive and simple.

Exactly. Beyond the CoffeeScript precedent (pave the cowpaths) there is the EIBTI Python dictum. We should not add a shorthand for function that materially differs in semantics. Alex Russell argued this point with respect to # freezing and joining (that is, uniting object identity up to the nearest relevant closure). It applies to |this|-binding too.

It is hard to beed => for "lexically bound |this| function" vs. -> for "dynamically bound |this| function". I've tried. Any form that defaults to lexical-|this| and looks like a function from (...){...} on is going to mislead programmers, exaclty as you show above.

/be

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110509/50397fa4/attachment.html>


More information about the es-discuss mailing list