On dropping @names

Andreas Rossberg rossberg at google.com
Fri Dec 7 00:15:03 PST 2012


On 6 December 2012 22:26, Claus Reinke <claus.reinke at talk21.com> wrote:
>>> I was hoping for something roughly like
>>>
>>>    let lhs = rhs; statements
>>>        // non-recursive, scope is statements
>>>
>>>    let { declarations }; statements        // recursive, scope is
>>> declarations and statements
>>
>> Problem is that you need mutual recursion between different binding forms,
>> not just 'let' itself.
>
> Leaving legacy var/function out of it, is there a problem with
> allowing mutually recursive new declaration forms in there?
>
>    let { // group of mutually recursive bindings
>
>        [x,y] = [42,Math.PI]; // initialization, not assignment
>
>        even(n) { .. odd(n-1) .. } // using short method form
>        odd(n) { .. even(n-1) .. } // for non-hoisting functions
>
>        class X { .. }
>        class C extends S { .. new X( odd(x) ) .. }
>        class S { }
>    };
>    if (even(2)) console.log(  new C() );

First of all, this requires whole new syntax for the let body. Second,
it doesn't eliminate the need for temporal dead zones at all. So what
does it gain? The model we have now simply is that every scope is a
letrec (which is how JavaScript has always worked, albeit with a less
felicitous notion of scope).

/Andreas


More information about the es-discuss mailing list