Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > FAQ Topic - What is a function statement? (2010-05-24)

Reply
Thread Tools

FAQ Topic - What is a function statement? (2010-05-24)

 
 
Ry Nohryb
Guest
Posts: n/a
 
      05-26-2010
On May 26, 8:32*pm, Garrett Smith <dhtmlkitc...@gmail.com> wrote:
>
> > "in ECMAScript a FunctionDeclaration is not a Statement; there are
> > places in a program where a Statement is permitted but a
> > FunctionDeclaration is not."

>
> Looks right to me. I'm going to update the entry with that.


Hurry up!
--
Jorge.
 
Reply With Quote
 
 
 
 
John G Harris
Guest
Posts: n/a
 
      05-26-2010
On Wed, 26 May 2010 at 09:18:14, in comp.lang.javascript, Ry Nohryb
wrote:
>On May 26, 5:24*pm, John G Harris <j...@nospam.demon.co.uk> wrote:


>> Gawd, you can't even copy-and-paste accurately! It's Statement,
>> singular.

>
>Either that or that you can't read, Johnny: ES3 specs, page 162: "A.4
>Statements"


So you copied this

A.4 Statements
Statement :

and then deleted the second word. Weird.


>> Surely you've seen this :
>>
>> * do Statement while ( Expression );
>>
>> Inside a 'do' statement you must put another Statement (exactly one).
>> You mustn't put a FunctionDeclaration there.

>
>You can do it and it's not an error, see:
>http://groups.google.com/group/comp....bf14d724e82d77
>sooo, could you please post a example that proves your (and Garrett's)
>point, *please* ?


You can write anything you like where it says Statement, but whatever it
is it's most certainly not an ECMAScript FunctionDeclaration.

If the browser or whatever accepts what you write it will then do
whatever its unpublished specification says, but it won't call it a
FunctionDeclaration because that would be a non-conformance in anything
claiming to conform to ECMAScript.

John
--
John Harris
 
Reply With Quote
 
 
 
 
Ry Nohryb
Guest
Posts: n/a
 
      05-26-2010
On May 26, 9:44*pm, John G Harris <j...@nospam.demon.co.uk> wrote:
> On Wed, 26 May 2010 at 09:18:14, in comp.lang.javascript, Ry Nohryb
> wrote:
>
> >On May 26, 5:24*pm, John G Harris <j...@nospam.demon.co.uk> wrote:
> >> Gawd, you can't even copy-and-paste accurately! It's Statement,
> >> singular.

>
> >Either that or that you can't read, Johnny: ES3 specs, page 162: "A.4
> >Statements"

>
> So you copied this
>
> * A.4 Statements
> * Statement :
>
> and then deleted the second word. Weird.


Not weird, it's called to copy-paste the text "A.4 Statements".

> >> Surely you've seen this :

>
> >> * do Statement while ( Expression );

>
> >> Inside a 'do' statement you must put another Statement (exactly one).
> >> You mustn't put a FunctionDeclaration there.

>
> >You can do it and it's not an error, see:
> >http://groups.google.com/group/comp....bf14d724e82d77
> >sooo, could you please post a example that proves your (and Garrett's)
> >point, *please* ?

>
> You can write anything you like where it says Statement, but whatever it
> is it's most certainly not an ECMAScript FunctionDeclaration.


Q: It looks like a function declaration, walks like a function
declaration, and quacks like a function declaration, and the specs
*permit* a function declaration there because syntax extensions are
permitted, so what ?
A: That this FAQ entry is pointless in the way it's worded right now.
--
Jorge.
 
Reply With Quote
 
John G Harris
Guest
Posts: n/a
 
      05-27-2010
On Wed, 26 May 2010 at 13:14:54, in comp.lang.javascript, Ry Nohryb
wrote:

<snip>
>Q: It looks like a function declaration, walks like a function
>declaration, and quacks like a function declaration, and the specs
>*permit* a function declaration there because syntax extensions are
>permitted, so what ?
>A: That this FAQ entry is pointless in the way it's worded right now.


You need to be accurate : ECMAScript permits extensions, but it's only a
Function Declaration if you say it is.

As you do say it is, you have to require it to be processed the way that
ECMA 262 requires Function Declarations to be processed. That is, the
declaration is processed *before* the code surrounding it is executed.

As a result, the function is declared unconditionally. Even if the
declaration is inside an if, while, or for statement the declaration is
always actioned even if code execution never passes through the
declaration text.

As Function Declarations are actioned unconditionally it is completely
pointless to hide them inside any kind of Statement. It is worth while
pointing this out to beginners.

You have demonstrated that this is what IE and a few others do. You have
also demonstrated that Mozilla is incompatible. It is worth while
warning beginners of this : they can't predict how their code is going
to behave if they use this extension.

John
--
John Harris
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ Topic - What is (function(){ /*...*/ })() ? (2011-02-12) FAQ server Javascript 14 02-13-2011 05:16 PM
OFF TOPIC:Re: C compiler question (I hope this is on topic) jacob navia C Programming 5 05-30-2010 02:22 PM
FAQ Topic - What questions are on-topic for CLJ? (2008-10-16) FAQ server Javascript 1 10-16-2008 12:03 PM
There are no more messages on this topic. All messages in this topic may have expired or been deleted Coach 02 Computer Support 1 03-12-2007 03:44 PM
FAQ topic pointers David Fisher C++ 6 02-03-2004 04:05 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57