> Not quite, the mechanism which does this in the spec is SetFunctionName > (http://www.ecma-international.org/ecma-262/6.0/#sec-setfunctionname > <http://www.ecma-international.org/ecma-262/6.0/#sec-setfunctionname>), and > it only works for specific syntactic constructs (eg, `foo = function() {}` -> > anonymous function is named “foo”, let x = () => {} -> anonymous arrow is > named “x”, etc). > > It does not apply to things like `compose(thingA, thingB)`, which is not an > anonymous function definition.These function names aren’t set at runtime, > it’s a parse-time operation, and depends on the productions that are parsed.
Ah, fascinating! That’s something that I overlooked. It is an odd mix of static and dynamic, though. For example: http://www.ecma-international.org/ecma-262/6.0/#sec-assignment-operators-runtime-semantics-evaluation <http://www.ecma-international.org/ecma-262/6.0/#sec-assignment-operators-runtime-semantics-evaluation> My understanding: – The actions themselves happen at runtime, not at compile time. – (1.e) IsAnonymousFunctionDefinition() is a static check that only holds if AssignmentExpression is an anonymous function expression (syntactically). – (1.e.i) is a dynamic check, SetFunctionName() happens dynamically, too. Wouldn’t it make sense to turn IsAnonymousFunctionDefinition() into a dynamic check, too? A check whether _rval_ is a function should suffice (given the check whether property `name` exists, later). -- Dr. Axel Rauschmayer a...@rauschma.de <mailto:a...@rauschma.de> rauschma.de
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss