On Mon, 03 Jan 2011 16:14:55 +0100, Dmitry Soshnikov
wrote:
Yes, the thing I wanted to underline, that the parser (because of
"ExpressionStatement" cannot begin with a `function` keyword) always
treats such production as a `FunctionDeclaration`. And that the
`SyntaxError`
relates to two
Sure, for those who wrote an ES parser (Hello, Peter ;)) this question
shouldn't be hard. And of course the parser themselves are good helpers in
this case.
Dmitry.
On Mon, Jan 3, 2011 at 5:52 AM, Ariya Hidayat wrote:
> If you have latest command-line SpiderMonkey or my little tool
> 'SyntaxJS'
On Sun, Jan 2, 2011 at 10:44 PM, Diego Perini wrote:
> On Sat, Jan 1, 2011 at 12:00 PM, Dmitry A. Soshnikov
> wrote:
> > On 01.01.2011 2:43, fernando trasvina wrote:
> >>
> >> Hi. very nice explanation but what i don't fully understand is why the
> >> grouping operator makes the parenthesis follo
Yep, it's also quite a good explanation.
Dmitry.
On Sun, Jan 2, 2011 at 5:32 PM, fernando trasvina wrote:
>
> On Jan 1, 2011, at 5:00 AM, Dmitry A. Soshnikov wrote:
>
> On 01.01.2011 2:43, fernando trasvina wrote:
>
> Hi. very nice explanation but what i don't fully understand is why the
> group
On Sun, Jan 2, 2011 at 3:14 PM, Lasse Reichstein wrote:
> On Fri, 31 Dec 2010 14:46:37 +0100, Dmitry A. Soshnikov <
> dmitry.soshni...@gmail.com> wrote:
>
> So, why does this code produces a SyntaxError:
>>
>> function () {
>> ...
>> }()
>>
> ...
>
> Try to provide as much complete explanatio
Hey very nice tool
Sent from my iPhone
On Jan 2, 2011, at 8:52 PM, Ariya Hidayat
wrote:
If you have latest command-line SpiderMonkey or my little tool
'SyntaxJS' (see https://github.com/ariya/syntaxjs for the code), you
can see the syntax tree produced by the parser.
For the case:
funct
If you have latest command-line SpiderMonkey or my little tool
'SyntaxJS' (see https://github.com/ariya/syntaxjs for the code), you
can see the syntax tree produced by the parser.
For the case:
function foo(x) { alert(x); }(1);
the output looks like:
{
"type": "Program",
"
On Sat, Jan 1, 2011 at 12:00 PM, Dmitry A. Soshnikov
wrote:
> On 01.01.2011 2:43, fernando trasvina wrote:
>>
>> Hi. very nice explanation but what i don't fully understand is why the
>> grouping operator makes the parenthesis following the function declaration
>> work as call.
>>
>> (function(x){
On Jan 1, 2011, at 5:00 AM, Dmitry A. Soshnikov wrote:
> On 01.01.2011 2:43, fernando trasvina wrote:
>> Hi. very nice explanation but what i don't fully understand is why the
>> grouping operator makes the parenthesis following the function declaration
>> work as call.
>>
>> (function(x){aler
On Fri, 31 Dec 2010 14:46:37 +0100, Dmitry A. Soshnikov
wrote:
So, why does this code produces a SyntaxError:
function () {
...
}()
...
Try to provide as much complete explanation as possible. Also try to
answer without cheating ;)
Because an ExpressionStatement may not start with th
I'm going to vacation, so tomorrow I won't be online, will answer later
if something.
Happy New Year again for everyone ;)
Dmitry.
On 02.01.2011 1:27, Dmitry A. Soshnikov wrote:
On 02.01.2011 1:22, Garrett Smith wrote:
On 1/1/11, Dmitry A. Soshnikov wrote:
On 02.01.2011 0:27, Garrett Smith
On 02.01.2011 1:22, Garrett Smith wrote:
On 1/1/11, Dmitry A. Soshnikov wrote:
On 02.01.2011 0:27, Garrett Smith wrote:
On 1/1/11, Dmitry A. Soshnikov wrote:
On 01.01.2011 4:01, Garrett Smith wrote:
The correct answer is that it's function declaration! And from this
step, there are two reas
On 1/1/11, Dmitry A. Soshnikov wrote:
> On 02.01.2011 0:27, Garrett Smith wrote:
>> On 1/1/11, Dmitry A. Soshnikov wrote:
>>> On 01.01.2011 4:01, Garrett Smith wrote:
>>> The correct answer is that it's function declaration! And from this
>>> step, there are two reasons of the issue.
>>>
>> No, t
Notice though, that I started the thread that explanation were
_incomplete_. I don't say they are completely were wrong. Again, they
were just incorrect in respect of the SyntaxError _reasons_. Of course
if the explanation is started from: /"we need to have a function
expression here, and there
On 02.01.2011 0:27, Garrett Smith wrote:
On 1/1/11, Dmitry A. Soshnikov wrote:
On 01.01.2011 4:01, Garrett Smith wrote:
On 12/31/10, fernando trasvina wrote:
why this is not treated the same way as:
function(x){}(1);
That is a SyntaxError. The most recent message on this thread (mine),
On 1/1/11, Dmitry A. Soshnikov wrote:
> On 01.01.2011 4:01, Garrett Smith wrote:
>> On 12/31/10, fernando trasvina wrote:
>>
>>
>>> why this is not treated the same way as:
>>>
>>> function(x){}(1);
>>>
>> That is a SyntaxError. The most recent message on this thread (mine),
>> explains that the
Happy new year ;)
> Remember, a A FunctionDeclaration's function is added to the
> VariableEnvironment in Variable Instantiation. It is not and cannot be an
> ExpressionStatement.
>
> An FunctionExpression is an ExpressionStatement; it is not bound to the VE
> (VariableEnvironment) on entering an
On 01.01.2011 13:42, Dmitry A. Soshnikov wrote:
On 01.01.2011 4:01, Garrett Smith wrote:
On 12/31/10, fernando trasvina wrote:
why this is not treated the same way as:
function(x){}(1);
That is a SyntaxError. The most recent message on this thread (mine),
explains that the production for
On 01.01.2011 0:55, Marc Harter wrote:
The thing is that (almost?) all explanations (I repeat -- books, articles, etc)
talked about `calling`, that is wrong. While the reason is that parentheses at
the end are not parentheses of a call (`Arguments` production), but just a
grouping operator (wi
On 01.01.2011 2:08, Garrett Smith wrote:
On 12/31/10, Marc Harter wrote:
The thing is that (almost?) all explanations (I repeat -- books, articles,
etc) talked about `calling`, that is wrong. While the reason is that
parentheses at the end are not parentheses of a call (`Arguments`
production),
On 01.01.2011 2:43, fernando trasvina wrote:
Hi. very nice explanation but what i don't fully understand is why the grouping
operator makes the parenthesis following the function declaration work as call.
(function(x){alert(x)}(1));
why this is not treated the same way as:
function(x){}(1);
On 01.01.2011 4:01, Garrett Smith wrote:
On 12/31/10, fernando trasvina wrote:
why this is not treated the same way as:
function(x){}(1);
That is a SyntaxError. The most recent message on this thread (mine),
explains that the production for ExpressionStatement explicitly
forbids an Express
On 12/31/10, fernando trasvina wrote:
> Hi. very nice explanation but what i don't fully understand is why the
> grouping operator makes the parenthesis following the function declaration
> work as call.
>
Did you read the last message I posted?
> (function(x){alert(x)}(1));
>
That is a Functio
Hi. very nice explanation but what i don't fully understand is why the grouping
operator makes the parenthesis following the function declaration work as call.
(function(x){alert(x)}(1));
why this is not treated the same way as:
function(x){}(1);
On Dec 31, 2010, at 7:46 AM, Dmitry A. Soshnik
On 12/31/10, Marc Harter wrote:
>
>> The thing is that (almost?) all explanations (I repeat -- books, articles,
>> etc) talked about `calling`, that is wrong. While the reason is that
>> parentheses at the end are not parentheses of a call (`Arguments`
>> production), but just a grouping operator
> The thing is that (almost?) all explanations (I repeat -- books, articles,
> etc) talked about `calling`, that is wrong. While the reason is that
> parentheses at the end are not parentheses of a call (`Arguments`
> production), but just a grouping operator (without an expression inside)
> w
On 31.12.2010 19:16, Marc Harter wrote:
The correct and full explanation is here:
http://dmitrysoshnikov.com/ecmascript/chapter-5-functions/#question-about-surrounding-parentheses
This is good Dmitry, thanks for sharing, I understood what you could and could
not do but didn't know the reasons
> The correct and full explanation is here:
> http://dmitrysoshnikov.com/ecmascript/chapter-5-functions/#question-about-surrounding-parentheses
This is good Dmitry, thanks for sharing, I understood what you could and could
not do but didn't know the reasons to that depth.
--
To view archived d
Just for those who don't use Twitter. I've just edited my
"ES3.Ch5.Functions" article in respect of explanation the "surrounding
parentheses". The thing is, that almost _all_ explanations (in books,
articles, etc) were at least very incomplete (and even wrong).
So, why does this code produces
29 matches
Mail list logo