In order to implement a tiny compiler that emits ECMAScript I need to know how strong a function object expression binds, i.e. what is the precedence of the “operator”
function(a1, a2, ...) { ... }?
For example, how is
function(a1, a2, ...) { ... } (b1, b2, ...)
supposed to be parsed? To get the wished for result, namely the application of b1, b2, … to the function object, I have to use parentheses around the function object in the Rhino interpreter.
Your
function(a1, a2, ...) { ... } (b1, b2, ...)is invalid, and should return a Syntax Error. ECMAScript has the concept of aFunctionDeclarationas well as that of aFunctionExpression. You may want to check out the following:While a
FunctionExpressionis an operator, theFunctionDeclarationis a special syntax used for declaring functions, which are automatically hoisted to the top of the enclosing scope.Wrapping a
functionin the grouping operator (parenthesis) will force the interpreter to treat it as aFunctionExpression.If you try the following in Firebug: