From: Benjamin 'BeRo' Rosseaux on 17 Jun 2010 19:35 Am 15.06.2010 09:00, schrieb Garrett Smith: > Proposed: > | Implementations that have the function statement extension process > | Fze as a Statement, in order. Others, including JScript, evaluate Fze > | upon entering the execution context that it appears in. Yet others, > | notably BESEN and DMDScript, throw a SyntaxError. > | > | For consistent behavior across implementations, do not use function > | statement; use either FunctionExpression or FunctionDeclaration > | instead. > BESEN supports function statements if the facile javascript emulation compatibility mode is activated (per example with compat("js") if the BESEN-specific extensions compatibility mode are also activated), but in the default mode without any activated compatibility mode flags BESEN doesn't support function statements, to be as possible fully ES5 specification complaint.
From: Garrett Smith on 17 Jun 2010 20:42 On 6/17/2010 4:35 PM, Benjamin 'BeRo' Rosseaux wrote: > Am 15.06.2010 09:00, schrieb Garrett Smith: > >> Proposed: >> | Implementations that have the function statement extension process >> | Fze as a Statement, in order. Others, including JScript, evaluate Fze >> | upon entering the execution context that it appears in. Yet others, >> | notably BESEN and DMDScript, throw a SyntaxError. >> | >> | For consistent behavior across implementations, do not use function >> | statement; use either FunctionExpression or FunctionDeclaration >> | instead. >> > > BESEN supports function statements if the facile javascript emulation > compatibility mode is activated (per example with compat("js") if the > BESEN-specific extensions compatibility mode are also activated), but in > the default mode without any activated compatibility mode flags BESEN > doesn't support function statements, to be as possible fully ES5 > specification complaint. > OK - I did not know about BESEN compatibility mode. | Yet others, notably DMDScript and default configuration of BESEN, | throw a SyntaxError. Garrett
From: Garrett Smith on 19 Jun 2010 16:03 On 2010-06-17 05:42 PM, Garrett Smith wrote: > On 6/17/2010 4:35 PM, Benjamin 'BeRo' Rosseaux wrote: >> Am 15.06.2010 09:00, schrieb Garrett Smith: >> [...] > > | Yet others, notably DMDScript and default configuration of BESEN, > | throw a SyntaxError. > I'll be updating the post early next week with this info, unless somebody has something they want to add. Garrett
From: Garrett Smith on 21 Jun 2010 16:27 On 2010-06-19 01:03 PM, Garrett Smith wrote: > On 2010-06-17 05:42 PM, Garrett Smith wrote: >> On 6/17/2010 4:35 PM, Benjamin 'BeRo' Rosseaux wrote: >>> Am 15.06.2010 09:00, schrieb Garrett Smith: >>> > [...] >> >> | Yet others, notably DMDScript and default configuration of BESEN, >> | throw a SyntaxError. >> > > I'll be updating the post early next week with this info, unless > somebody has something they want to add. > After reviewing, I decided that the fact of three different known interpreations was not explicitly stated. Since this is an important point, I added it. "Code that uses function statement has three known interpretations." The proposed text, so far is this: +----------------------------------------------------------------------+ What is a function statement? The term function statement has been widely and wrongly used to describe a FunctionDeclaration. This is misleading because in ECMAScript, a FunctionDeclaration is not a Statement; there are places in a program where a Statement is permitted but a FunctionDeclaration is not. To add to this confusion, some implementations, notably Mozillas', provide a syntax extension called function statement. This is allowed under section 16 of ECMA-262, Editions 3 and 5. Example of nonstandard function statement: // Nonstandard syntax, found in GMail source code. DO NOT USE. try { // FunctionDeclaration not allowed in Block. function Fze(b,a){return b.unselectable=a} /*...*/ } catch(e) { _DumpException(e) } Code that uses function statement has three known interpretations. Some implementations process Fze as a Statement, in order. Others, including JScript, evaluate Fze upon entering the execution context that it appears in. Yet others, notably DMDScript and default configuration of BESEN, throw a SyntaxError. For consistent behavior across implementations, do not use function statement; use either FunctionExpression or FunctionDeclaration instead. Example of FunctionExpression (valid): var Fze; try { Fze = function(b,a){return b.unselectable=a}; /*...*/ } catch(e) { _DumpException(e) } Example of FunctionDeclaration (valid): // Program code function aa(b,a){return b.unselectable=a} +----------------------------------------------------------------------+ Garrett
From: John G Harris on 22 Jun 2010 11:05
On Mon, 21 Jun 2010 at 13:27:23, in comp.lang.javascript, Garrett Smith wrote: <snip> >What is a function statement? > >The term function statement has been widely and wrongly used to >describe a FunctionDeclaration. This is misleading because in >ECMAScript, a FunctionDeclaration is not a Statement; there are places >in a program where a Statement is permitted but a FunctionDeclaration >is not. To add to this confusion, some implementations, notably >Mozillas', provide a syntax extension called function statement. This >is allowed under section 16 of ECMA-262, Editions 3 and 5. <snip> "This is allowed" : I prefer "Syntax extensions are allowed". At first glance it looked as though function statements were mentioned in the standard and explicitly permitted. John -- John Harris |