function(){}(); 
December 7th, 2007, 11:45 AM
| | | |
What's wrong with this function? | 
December 7th, 2007, 12:25 PM
| | | | 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. | 
December 7th, 2007, 12:25 PM
| | | | 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 ? | 
December 7th, 2007, 12:55 PM
| | | | 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. | 
December 7th, 2007, 01:15 PM
| | | | 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 ? | 
December 7th, 2007, 01:25 PM
| | | | 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. | 
December 7th, 2007, 01:35 PM
| | | | 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(){})(); | 
December 7th, 2007, 01:45 PM
| | | | 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. | 
December 7th, 2007, 02:55 PM
| | | | 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. | 
December 8th, 2007, 01:05 AM
| | | | 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 | 
December 8th, 2007, 07:35 PM
| | | | 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. |  | | | | /bytes/about
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 225,662 network members.
|