let function
Brendan Eich
brendan at mozilla.org
Fri May 22 22:35:17 UTC 2015
Guillermo wondered whether we couldn't have
let f(x) { return x*x; };
as a shorthand for the block-bodied arrow
let f = (x) => { return x * x; }
The obvious question is how to enable expression bodies?
let f(x) x * x;
looks like it is missing the =>, but if we require that:
let f(x) => x * x;
then why not for the block-bodied case too, so readers are better
reminded that `this` is from the outer scope, ditto `arguments`?
Decisions, decisions!
/be
Brendan Eich wrote:
> Your point about decorators vs. hoisting is good, everyone should keep
> it in mind. Still doesn't mean we can't add a special form for const
> function, as followups aver.
>
> /be
>
> Alexander Jones wrote:
>> On 19 May 2015 at 02:02, Brendan Eich <brendan at mozilla.org
>> <mailto:brendan at mozilla.org>> wrote:
>>
>>
>> This seems like a better shorthand to discuss, compared to `let
>> function` (which function-in-block covers already, as noted).
>>
>>
>> function-in-block does not have the same semantics as the proposed
>> "let function". It hoists, thus has no TDZ, and appears to preclude a
>> reasonable decorator syntax behaviour, and it has no provisions for
>> const binding, i.e. "const function".
>>
>> let f(x) => y
>>
>> appears attractive indeed, but by virtue of it being an arrow
>> function, has lexical this and no prototype property. Also no
>> generator syntax, unless I'm missing something?
>>
>> Cheers
> _______________
More information about the es-discuss
mailing list