On Feb 26, 2015, at 4:10 AM, Leon Arnott wrote:
> The twitter thread starts here:
> https://twitter.com/getify/status/570614952605560838 and basically boils down
> to the observation that this:
> ```
> ({ f() { return f; }}.f()) /* ReferenceError (probably) */
> ```
> is not semantically identical to this:
> ```
> ({ f: function f() { return f; } }.f()) /* function f() */
> ```
> That is, concise methods cannot seamlessly recursively call or reference
> themselves. (Personally, I feel like concise methods *should* be a binding
> within themselves in a manner identical to named function expressions, but if
> this has been discussed before and discarded then I understand.)
>
> You may notice that both of the methods above have the same name, "f", in
> spite of one lacking the lexical binding. Formerly, named functions always
> (barring internal var statements etc.) had lexical bindings to themselves,
> and the whole ES6 function name inference dealie breaks this correlation. I
> don't think this is really an important issue, though - assuming that a
> `.name` property equated to a binding was not a safe assumption (especially
> since IE never implemented `.name` but did support the binding).
Note that property names are restricted to being valid identifiers. Note of
the following concise methods could possibly use their property name as a
lexical binding:
let o = {
42() {},
" this is not an identifier"() {},
""() {},
if() {},
[Symbol.iterate]() {}
};
We may have a universal way for functions to self reference themselves i post
ES6.
allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss