Another lingering objection to arrows is this-binding (=> vs. ->).

*If* it is possible to make 'function'-free functions work, then how
about dropping the implicit bindings for 'arguments' and 'this' for
the short form? Then the 'function' keyword would be a modifier
on the short form, to re-introduce these implicit bindings.
That would support current code while connecting the semantic
difference (wrt 'this') to a more visible hint than -> vs =>.

This would still leave room for having both short functions and block lambdas, as they serve different uses

function f(..) {..}
   binds 'this', binds 'arguments', binds 'return'

f(..) {..}
   no 'this', no 'arguments', binds 'return'

{|..| ..}
   no 'this', no 'arguments', does not bind 'return'

(binding 'return' means that 'return' is local to this construct;
not binding 'return' means that 'return' is bound non-locally,
in a lexically enclosing construct).

There is at least one further dimension to this (abstracting
over expressions vs abstracting over statements), so there
may be room/need for another construct/modifier, to get
a more orthogonal design. It is part convenience, part historical accident that Javascript has 'running a block' mixed together with 'calling a callable'.

Claus

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to