Upcoming talk on ES6 in Russia

Brendan Eich brendan at mozilla.com
Sat Mar 23 22:21:06 PDT 2013

Jorge Chamorro wrote:
> On 23/03/2013, at 19:41, Axel Rauschmayer wrote:
>> Arrow functions are a good example: A more JavaScript-y syntax would have been `fn`:
>>      let squares = [1,2,3].map(fn(x) { return x*x });
>> Or:
>>      let squares = [1,2,3].map(fn(x) x*x);
>> However, due to backward compatibility that syntax wasn’t possible.
> I don't think that's true: old code (that doesn't use the new syntax) would continue to run, and new code that opts-in to es6 (using the new syntax) would reject the (very rare) old uses of ƒ as in function ƒ(){} or var ƒ; or ƒ=xxx;, and would allow the new forms, e.g. .map(ƒ(n) ...).

If you mean ƒ (florin, option-f on Mac keyboards) then no: the problem 
is that's an incompatible change and liable to have different meaning in 
old engines.

(Note also that "new code ... would reject" doesn't make sense: it's an 
engine that accepts or rejects code.)

a = [1,2,3]
function ƒ(x){return function(y) {return x*y} }
var z = 3
var g = ƒ(z)
a.map(g) // [3, 6, 9]

In new engines, the initializer for var g is a florin-function 
expression, ƒ(z) z*z (note the newline before the body expression; note 
also it doesn't matter whether we use ƒ or fn or something else that's a 
legal identifier in ES1-6), and the author intends a.map to square the 
values in [1,2,3].

But in old engines, var g's initializer is a call to ƒ(z), and the z*z 
on the next line is a useless expression statement.

There's no "would reject" case here. Same input, two different meanings.

Adding a [no LineTerminator here] restriction on the florin-function 
production between head and body just makes a hazard where removing 
lines (minification) changes semantics.

> It's ~ the same case as `with` and if they really wanted it could be done, I don't buy the "it wasn't possible", no.

'with' has nothing to do with this. It's rejected by ES5 strict, but so 

> But as bluntly as @rwaldron put it the other day: "arrows are here to stay" (full stop)... well, ok! but I for one don't like them as much.

The relevant advantage here is that => was illegal syntax in ES1-5, so 
there's no backward incompatibility, as there would be for ƒ or fn or 
similar identifiers.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130323/d8c4833e/attachment-0001.html>

More information about the es-discuss mailing list