Le 13/07/2013 20:55, Jeff Walden a écrit :
On 07/12/2013 04:59 PM, Andrea Giammarchi wrote:
one more thing ... I believe this will impact arrow function too since is
basically bound callbacks all over the place (or at least this is how I believe
it will be transpiled)
Sadly, based on the arrow-function patches I've reviewed in SpiderMonkey, I
don't believe this will be necessarily true. Arrow functions and bind-bound
functions are two rather different beasts. Bind-bound functions are
potentially constructible; arrow functions never are. |arguments.callee|
inside a function that's been bound doesn't refer to the bound function -- it
refers to the lexical entity.
One of these things I didn't know (and didn't want to know) about the
language...
(That is, |function f() { return arguments.callee; } f.bind(null)()| is |f|,
not |b|.) |arguments.callee| inside an arrow function -- at least, so long as
arrow functions aren't automatically strict, which decision I would revisit --
refers to the arrow function.
arguments.callee is poisoned is strict mode, so the difference you're
referring only affects non-strict. Should we care? I know I don't.
In general, it should be expected from developers to be in strict mode.
They also shouldn't be using the "arguments" object...
"which decision I would revisit"
=> I disagree. Implicit strictness at the function level would surprise
people a lot. Maybe break their code when turning a function expression
to an arrow function.
Implicit strictness at the module or class level will already surprise
people a lot.
I expect there are other differences I'm not yet aware of, that would affect
having a common implementation of the two concepts.
Even in strict mode? If there are no differences in strict mode, I don't
think we should care.
It seems like a pretty bad idea to me for arrow functions to not be
substantially semantically similar to bind-bound functions, but they are as it
stands now. I wish I had the time to sit down and think through a solid
unification of the two concepts.
Hopefully by simplifying how bound functions work?
David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss