Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upConsider dropping the "optimization" for functions without parameter default value initializers #623
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
allenwb
Jun 28, 2016
Member
I considered that possibility when I updated the algorithm to include the arguments environment. The reason I didn't go that route is that I wanted to emphasize that the separate environment was there solely to support parameter lists with defaults. Plus the overall algorithm is complicated enough that it seemed wise to normatively specify the intended semantics for the "optimized" case rather than leaving it to each implementation to figure that out.
The optimized branch could be eliminated and replaced with an informative note. However, at the time, carefully crafting the language of such a note seemed harder than just including both paths in the algorithm.
|
I considered that possibility when I updated the algorithm to include the arguments environment. The reason I didn't go that route is that I wanted to emphasize that the separate environment was there solely to support parameter lists with defaults. Plus the overall algorithm is complicated enough that it seemed wise to normatively specify the intended semantics for the "optimized" case rather than leaving it to each implementation to figure that out. The optimized branch could be eliminated and replaced with an informative note. However, at the time, carefully crafting the language of such a note seemed harder than just including both paths in the algorithm. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jorendorff
Jun 28, 2016
Plus the overall algorithm is complicated enough that it seemed wise to normatively specify the intended semantics for the "optimized" case rather than leaving it to each implementation to figure that out.
Thanks for thinking of us implementors, and thanks for the fast response.
The NOTE in step 26.a. should say that this is meant to illustrate a pure optimization that implementations may do. As it stands, I was concerned that the branch might have been done, rather, because the two branches were not the same, that adding even a trivial default like = 0 changed behavior in some very subtle way that we were missing.
Honestly, though, I think I'd rather this be removed. Implementations will likely choose to optimize this some other way. For example, nested environments can often be fused; this particular optimization might fall out for free, as a special case of a more general analysis that looks for such opportunities.
jorendorff
commented
Jun 28, 2016
Thanks for thinking of us implementors, and thanks for the fast response. The NOTE in step 26.a. should say that this is meant to illustrate a pure optimization that implementations may do. As it stands, I was concerned that the branch might have been done, rather, because the two branches were not the same, that adding even a trivial default like Honestly, though, I think I'd rather this be removed. Implementations will likely choose to optimize this some other way. For example, nested environments can often be fused; this particular optimization might fall out for free, as a special case of a more general analysis that looks for such opportunities. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
littledan
Jun 29, 2016
Member
I like @jorendorff 's suggestion. Our implementation has a conditional too, but we only add the scope if we see sloppy direct eval being called anywhere in the function body or defaults.
|
I like @jorendorff 's suggestion. Our implementation has a conditional too, but we only add the scope if we see sloppy direct eval being called anywhere in the function body or defaults. |
jorendorff commentedJun 28, 2016
•
edited
Currently, FunctionDeclarationInstantiation branches at step 26:
There's a special case (step 26) for functions without defaults; and a general case (step 27) that looks like it would work whether you have defaults or not.
Our implementation will in fact branch like this, somewhere. But why have the special case in the spec? It reads like a pure optimization, which seems undesirable for a spec. I think @allenwb wrote this - Allen, do you know what this is for?