function hoisting like var

Brendan Eich brendan at
Sat Jul 26 01:15:49 PDT 2008

On Jul 26, 2008, at 4:03 AM, Ingvar von Schoultz wrote:

> waldemar at wrote:
>> Ingvar von Schoultz wrote:
>>> waldemar at wrote:
>>>> I'm trying to keep the language relatively simple.
>>> You can't get away from supporting this:
>>>     {
>>>         function a(){}
>>>         var b = a;
>>>     }
>> What do you mean?  This is a syntax error in both ES3 and ES3.1.
> It works fine in Firefox 2, Konqueror 3, Opera 9, Internet
> Explorer 6, and server-side Rhino with JavaScript 1.6.

Waldemar meant precisely what he wrote: ES3 and draft ES3.1 -- the  
specifications, not random JS implementations.

> Five platforms out of five. Can you throw a syntax error here
> and claim to be compatible?

The implementations are not compatible. Please see the earlier es4- 
discuss thread with subject "Function declarations in statements" at: 

>> It does not already exist in ES3 or ES3.1.
> It exists on platforms as described above. I assumed that ES4
> would be compatible.

No, because it is impossible to be compatible with conflicting  
extensions to ES3 that browsers have implemented. The conflicts and  
undesirable intersection semantics are why ES4 proposes, and ES3.1  
considered but deferred, block-scoped functions that must be direct  
children of braced blocks. This requires opt-in versioning, which is  
why ES3.1 deferred it.


-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Es4-discuss mailing list