return when desugaring to closures
Brendan Eich
brendan at mozilla.com
Mon Oct 13 16:54:48 PDT 2008
On Oct 13, 2008, at 4:09 PM, Brendan Eich wrote:
> On Oct 13, 2008, at 4:01 PM, Waldemar Horwat wrote:
>
>> Brendan Eich wrote:
>>> If using an uninitialized let binding is an error, then hoisting is
>>> pointless except to make the statements between start of block and
>>> the
>>> let declaration a dead zone for the binding name. This fits the
>>> ancient, weak but not entirely worthless post-hoc rationale for var
>>> hoisting (to avoid confusion among novice or inexperienced
>>> programmers
>>> by making many scopes, each implicitly opened by var), but it's not
>>> particularly useful.
>>
>> This was our agreement from the ES4 days. It's very useful, in that
>> it allows mutually recursive lambdas.
>
> For function bindings, yes, of course -- but we were talking about let
> bindings (I thought). For let (there is no 'let function') bindings,
> how? Could you give an example?
Obvious example:
{
let even = function (n) n == 0 || odd(n - 1);
let odd = function (n) n != 0 && even(n - 1);
print(even(42), odd(42));
print(even(99), odd(99));
}
My words about function binding meant to suggest: why not require
users to write
{
function even(n) n == 0 || odd(n - 1);
function odd(n) n != 0 && even(n - 1);
...
}
But I'm not arguing that we shouldn't hoist let to top of block, only
trying to justify my "not particularly useful" assertion ;-).
/be
More information about the Es-discuss
mailing list