Newsgroups: comp.lang.javascript
From: Garrett Smith <dhtmlkitc...@gmail.com>
Date: Tue, 20 Apr 2010 17:18:38 -0700
Local: Tues, Apr 20 2010 8:18 pm
Subject: Re: Closing parenthesis in function's definition followed by its call
Johannes Baagoe wrote: Actually that is a FunctionStatement, an allowed syntax extension. > Garrett Smith : >> Then what is wrong with an implementation treating a FunctionExpression > Nothing at all, a FunctionExpression *is* a Function Definition. >> And if the answer is nothing (which is the correct answer) then why > Apparently, MDC got at least *its* wording wrong : what "Some > MDC's bone of contention is this: > if (0) { > According to MDC, we have a function *expression*, which means that The documentation there uses "function statement" in two ways: <https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference:Functi...> > At least V8 (Chrome) considers it a function *declaration*, i.e., The function declaration (function statement) > zero is a function. Edit section > I am not sure myself - understanding the specs requires more than Microsoft has a well known bug with named function expressions. There > I am willing to spend on the problem, after having given it a try > both in 3rd and 5th ed. If someone can explain it in plain words to > an ordinarily stupid programmer like me, I shall be very grateful. > In any case, someone is wrong. It may be Microsoft (that was Jorge's are many posts in the archives, but Juriy's article explains it in one place (that is also linked from the FAQ). > But for exactly that reason, I think whoever is wrong has at least a Not at all. The ECMAScript specification has no provision for > "lame excuse", lamer, to be sure, in the case of people who get paid > to get it right than in mine. Namely that the specs are horrible: > FunctionDeclaration : > mean that when the FunctionExpression has its optionalIdentifier, there FunctionDeclaration to appear where a Statement may appear. However, an ExpressionStatement may appear where a Statement is allowed. > How is it resolved? Well... happy reading of the specs :) | Statement | Block | VariableStatement | EmptyStatement | ExpressionStatement | IfStatement | IterationStatement | ContinueStatement | BreakStatement | ReturnStatement | WithStatement | LabelledStatement | SwitchStatement | ThrowStatement | TryStatement FunctionDeclaration is not on that list. ExpressionStatement is. ExpressionStatement An ExpressionStatement can't start with "{" because that would create A MemberExpression is a Left-Hand-Side Expression. MemberExpression : A FunctionExpression is an MemberExpression. A FunctionDeclaration is not an Expression; it is a SourceElement. Spidermonkey adds FunctionStatement. JScript adds FunctionDeclaration, In JScript, upon entering an execution context, each | For each FunctionDeclaration or FunctionExpression in the code, in You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||