Will FP ever have a great Stack Trace story in JS?

Axel Rauschmayer rauschma at icloud.com
Thu Sep 17 02:18:19 UTC 2015

> 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
axel at rauschma.de <mailto:axel at rauschma.de>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150917/0585f041/attachment.html>

More information about the es-discuss mailing list