Revenge of the double-curly [Was: return when desugaring to closures]

liorean liorean at
Fri Oct 10 06:17:49 PDT 2008

> On 2008-10-10, at 02:29EDT, Brendan Eich wrote:
>> An agreement from TC39 this past sprint was that function definitions
>> directly nested in blocks, not specified by ES3, defined block-local
>> (let) bindings.

2008/10/10 P T Withington <ptw at>:
> Holy smokes.  Does that mean we are all going to be writing
>   function ... () {{
>     ...
>   }}
> to get 'normal' scoping of function body declarations???  Will `var`
> mean `let` in those double-curly bodies?  Might as well let `let` not
> be a keyword...

Haven't we been through this before? ES3 doesn't allow this, but all
browsers do allow it. And all browsers have slightly or entirely
different behaviour. The behaviour of Opera and IE on one hand and
Mozilla and Safari on the other hand is entirely incompatible.

The Harmony decision is incompatible with all browsers, because the
function wouldn't be usable before the block (breaks IE and Opera
behaviour) and would fall out of scope when the block exits (breaks
Mozilla and Safari behaviour).

For example, this works in Mozilla:
        function fn(){return 'then-path';}
        function fn(){return 'else-path';}
    fn(); // => 'then-path'

This would be broken by the Harmony design. On the other hand, the
other browsers will result in 'else-path' in the current situation.
(Is this a change in Safari? Unless I'm misremembering the results
last time bundled Safari with Mozilla on this one.)
David "liorean" Andersson

More information about the Es-discuss mailing list