16:11 | <Michael Ficarra> | Someone asked questions about the notes in the scope analysis section in the spec (see https://www.zhihu.com/question/479537603 if u can read chinese):
- At the top level of a Script, function declarations are treated like var declarations rather than like lexical declarations.
- At the top level of a Module, function declarations are treated like lexical declarations rather than like var declarations.
- At the top level of a function, or script, function declarations are treated like var declarations rather than like lexical declarations.
- At the top level of a function or script, inner function declarations are treated like var declarations.
I guess all these notes are try to explain whether function declaration are included in the return result of the syntax-directed operations. But it may be not easy to understand if not familiar with the spec. Can we make the note much explicit? For example, can we change the first note to "...are treated like var declarations rather than like lexical declarations, So they are not included." ?
And there are two specific questions in the original post: A. Is there any differences between capitalized "Script" (in the 1st note) and "script" (in the 3rd and 4th note)? B. What "inner functions declarations" mean it the 4th note?
For question A, I suppose there is no difference, I guess "Script" is capitalized just because it's a link to the "Script" section. I don't know the convention of the spec, but it seems a little bit inconsistent that in one note it's linked and capitalized, in another notes they are not.
For question B, I think the confusion is "inner functions" of "script", I can understand what that mean, but it may be only common to say "inner functions" of a "function" (I'm not sure about that)?
Submit a PR or open an issue on tc39/ecma262 if you're unsure what to do. |