return when desugaring to closures
Waldemar Horwat
waldemar at google.com
Tue Oct 14 11:19:25 PDT 2008
Brendan Eich wrote:
>> What did you mean by "had better fail to compile"? Other than the
>> type annotation, there is nothing about
>>
>> function f() {
>> x = 15;
>> ...
>> var t = some_runtime_expression;
>> ...
>> var x:t = ...
>> }
>>
>> that ought to fail to compile.
>
> The assignment to x in that temporal dead zone before t's initializer
> has been evaluated.
>
> Why is this different if you s/var x/let x/?
Ah, ok. That's good news! For a long time I wanted to make statically detectable uses of a variable before its let or const declaration runs to be compile-time errors. You can't detect all of them due to closures, but you can detect most in practice. I'm glad you agree.
Waldemar
More information about the Es-discuss
mailing list