Connecting Tech Pros Worldwide Help | Site Map

function(){}();

ballpointpenthief
Guest
 
Posts: n/a
#1: Dec 7 '07
What's wrong with this function?
Henry
Guest
 
Posts: n/a
#2: Dec 7 '07

re: function(){}();


On Dec 7, 11:44 am, ballpointpenthief <ballpointpenth...@yahoo.co.uk>
wrote:
Quote:
What's wrong with this function?
The total absence of any source code.
Bruno Desthuilliers
Guest
 
Posts: n/a
#3: Dec 7 '07

re: function(){}();


Henry a écrit :
Quote:
On Dec 7, 11:44 am, ballpointpenthief <ballpointpenth...@yahoo.co.uk>
wrote:
Quote:
>What's wrong with this function?
>
The total absence of any source code.
Is this supposed to be wrong ?
Henry
Guest
 
Posts: n/a
#4: Dec 7 '07

re: function(){}();


On Dec 7, 12:25 pm, Bruno Desthuilliers wrote:
Quote:
Henry a écrit :
Quote:
>On Dec 7, 11:44 am, ballpointpenthief <ballpointpenth...@yahoo.co.uk>
>wrote:
Quote:
>>What's wrong with this function?
>
Quote:
>The total absence of any source code.
>
Is this supposed to be wrong ?
Where a function is concerned the only thing that is right about not
having any source code is that the absence of code avoids syntax
errors.

Bruno Desthuilliers
Guest
 
Posts: n/a
#5: Dec 7 '07

re: function(){}();


Henry a écrit :
Quote:
On Dec 7, 12:25 pm, Bruno Desthuilliers wrote:
Quote:
>Henry a écrit :
Quote:
>>On Dec 7, 11:44 am, ballpointpenthief <ballpointpenth...@yahoo.co.uk>
>>wrote:
>>>What's wrong with this function?
>>The total absence of any source code.
>Is this supposed to be wrong ?
>
Where a function is concerned the only thing that is right about not
having any source code is that the absence of code avoids syntax
errors.
Indeed !-)

But what I meant was : is this (I mean, the OP snippet) supposed to be
wrong *wrt/ language specs* ? AFAICT it should be legal - even if
obviously useless ?


AKS
Guest
 
Posts: n/a
#6: Dec 7 '07

re: function(){}();


On 7 дек, 18:10, Bruno Desthuilliers <bruno.
42.desthuilli...@wtf.websiteburo.oops.comwrote:
Quote:
AFAICT it should be legal - even if obviously useless ?
This expression contradicts the specification which says:

12.4 Expression Statement
Syntax
ExpressionStatement :
[lookahead ∉ {{, function}] Expression ;
... an ExpressionStatement cannot start with the function keyword
because that might make it ambiguous with a FunctionDeclaration.
ballpointpenthief
Guest
 
Posts: n/a
#7: Dec 7 '07

re: function(){}();


On Dec 7, 1:21 pm, AKS <aksus...@yandex.ruwrote:
Quote:
On 7 дек, 18:10, Bruno Desthuilliers <bruno.
>
42.desthuilli...@wtf.websiteburo.oops.comwrote:
Quote:
AFAICT it should be legal - even if obviously useless ?
>
This expression contradicts the specification which says:
>
12.4 Expression Statement
Syntax
ExpressionStatement :
[lookahead ∉ {{, function}] Expression ;
... an ExpressionStatement cannot start with the function keyword
because that might make it ambiguous with a FunctionDeclaration.
The corrected version is:
(function(){})();
AKS
Guest
 
Posts: n/a
#8: Dec 7 '07

re: function(){}();


On 7 ÄÅË, 18:33, ballpointpenthief <ballpointpenth...@yahoo.co.uk>
wrote:
Quote:
On Dec 7, 1:21 pm, AKS <aksus...@yandex.ruwrote:
Quote:
>
The corrected version is:
(function(){})();
Yes, of course, and I tell you why - this time you use the grouping
operator (11.1.6 The Grouping Operator), which turns function
statement into valid function expression.

Henry
Guest
 
Posts: n/a
#9: Dec 7 '07

re: function(){}();


On Dec 7, 1:10 pm, Bruno Desthuilliers wrote:
Quote:
Henry a écrit :
Quote:
>On Dec 7, 12:25 pm, Bruno Desthuilliers wrote:
Quote:
>>Henry a écrit :
>>>On Dec 7, 11:44 am, ballpointpenthief <ballpointpenth...@yahoo.co.uk>
>>>wrote:
>>>>What's wrong with this function?
>>>The total absence of any source code.
>>Is this supposed to be wrong ?
>
Quote:
>Where a function is concerned the only thing that is right about not
>having any source code is that the absence of code avoids syntax
>errors.
>
Indeed !-)
>
But what I meant was : is this (I mean, the OP snippet) supposed to be
wrong *wrt/ language specs* ? AFAICT it should be legal - even if
obviously useless ?
And what I meant (I said pretty explicitly) was that there was no
snippet in the OP to judge.
Csaba Gabor
Guest
 
Posts: n/a
#10: Dec 8 '07

re: function(){}();


On Dec 7, 2:33 pm, ballpointpenthief <ballpointpenth...@yahoo.co.uk>
wrote:
Quote:
On Dec 7, 1:21 pm, AKS <aksus...@yandex.ruwrote:
...
Quote:
Quote:
This expression contradicts the specification which says:
>
Quote:
12.4 Expression Statement
Syntax
ExpressionStatement :
[lookahead ∉ {{, function}] Expression ;
... an ExpressionStatement cannot start with the function keyword
because that might make it ambiguous with a FunctionDeclaration.
>
The corrected version is:
(function(){})();
Please see posts 2 and 5 of the following April 10, 2006 thread for a
more detailed explanation:
http://groups.google.com/group/comp....638ebc5a4fe21/

Csaba Gabor from Vienna
Dr J R Stockton
Guest
 
Posts: n/a
#11: Dec 8 '07

re: function(){}();


In comp.lang.javascript message <173d0b5e-74d4-4b84-b24e-e33fbbbffc3e@e2
5g2000prg.googlegroups.com>, Fri, 7 Dec 2007 03:44:11, ballpointpenthief
<ballpointpenthief@yahoo.co.ukposted:
Quote:
>What's wrong with this function?
Reading FAQ 2.3 para 2 sentence 2 will help you to understand other
replies.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Closed Thread