Happy new year ;)
> Remember, a A FunctionDeclaration's function is added to the
> VariableEnvironment in Variable Instantiation. It is not and cannot be an
> ExpressionStatement.
>
> An FunctionExpression is an ExpressionStatement; it is not bound to the VE
> (VariableEnvironment) on entering an execution context. A FunctionExpression
> is disabiguated from a FunctionDeclaration by the fact that an
> ExpressionStatement can't start with the `function` keyword.
>
> When `f` is called, a VariableEnvironment (VE) is created. For each
> FunctionDeclaration in the FunctionBody of `f` the Identifier of that
> FD is added to the VE.
>
The point that Dmitry is trying to explain has nothing to do with the
running, is a topic within the field of parsing. The grammar that you can
see in specification is equivalent to
*SourceElements*: ( Statement | *FunctionDeclaration* )+
*Program*: SourceElements?
*FunctionBody*: SourceElements?
*FunctionDeclaration* : function Identifier
(FormalParameterList?){FunctionBody*}*
The source will be divided into *Statements* and *FunctionDeclarations*,
and a FunctionDeclaration ends in a "*}*", therefore the arguments of a
hypothetical call haven't connection with "their function", the parser will
place they in the following SourceElement, an ExpressionStatement.
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]