Connecting Tech Pros Worldwide Help | Site Map

function(){}();

 
LinkBack Thread Tools Search this Thread
  #1  
Old December 7th, 2007, 10:45 AM
ballpointpenthief
Guest
 
Posts: n/a
Default function(){}();

What's wrong with this function?

  #2  
Old December 7th, 2007, 11:25 AM
Henry
Guest
 
Posts: n/a
Default 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.
  #3  
Old December 7th, 2007, 11:25 AM
Bruno Desthuilliers
Guest
 
Posts: n/a
Default 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 ?
  #4  
Old December 7th, 2007, 11:55 AM
Henry
Guest
 
Posts: n/a
Default 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.

  #5  
Old December 7th, 2007, 12:15 PM
Bruno Desthuilliers
Guest
 
Posts: n/a
Default 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 ?


  #6  
Old December 7th, 2007, 12:25 PM
AKS
Guest
 
Posts: n/a
Default 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.
  #7  
Old December 7th, 2007, 12:35 PM
ballpointpenthief
Guest
 
Posts: n/a
Default 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(){})();
  #8  
Old December 7th, 2007, 12:45 PM
AKS
Guest
 
Posts: n/a
Default 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.

  #9  
Old December 7th, 2007, 01:55 PM
Henry
Guest
 
Posts: n/a
Default 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.
  #10  
Old December 8th, 2007, 12:05 AM
Csaba Gabor
Guest
 
Posts: n/a
Default 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
  #11  
Old December 8th, 2007, 06:35 PM
Dr J R Stockton
Guest
 
Posts: n/a
Default 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.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.