>> I meant: One can already write methods (functions with dynamic |this|) in a
>> very concise manner, thanks for Allen’s object literal extensions. Then you
>> have to ask: Do we really need the dynamic this arrow ->, or can we make do
>> with just the lexical this arrow =>.
>
> We do not propose to cripple the shorter syntax. The dynamic-this use-cases
> for functions are at least as common as "var self=this;... function(){...
> self...}" use-cases for lexical this, or roughly about the same (in my
> experience -- anyone have data?).
Are functions that depend on dynamic |this| ever *not* methods? Wouldn’t you
always want to use an object literal for methods, especially if some features
(such as |super|) depend on it?
Isn’t it then a case of
{ foo: (x) -> { ... } }
versus
{ foo(x) { ... } }
On the other hand, if the ability to omit returns can only be got via
arrow->functions then I can see why you would want to keep them for methods.
But even implicit returns seem to matter most in non-method settings (e.g. if a
function is the argument of a function).
Maybe I just like the distinction introduced by block lambdas too much:
- dynamic this --> existing functions and methods
- lexical this --> new, more compact construct, mainly used as the argument of
functions and methods.
This distinction works well as a rule of thumb and keeps things easy to explain.
--
Dr. Axel Rauschmayer
[email protected]
twitter.com/rauschma
home: rauschma.de
blog: 2ality.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss