return when desugaring to closures
David-Sarah Hopwood
david.hopwood at industrial-designers.co.uk
Mon Oct 13 22:07:57 PDT 2008
Waldemar Horwat wrote:
> I am talking about let bindings. Lars brought up at that meeting. I did not find the use cases particularly convincing, but the dead zone is compelling. There are four ways to do this:
> A1. Lexical dead zone. References textually prior to a definition in the same block are an error.
> A2. Lexical window. References textually prior to a definition in the same block go to outer scope.
> B1. Temporal dead zone. References temporally prior to a definition in the same block are an error.
> B2. Temporal window. References temporally prior to a definition in the same block go to outer scope.
>
> Let's take a look at an example:
>
> let x = "outer";
> function g() {return "outer"}
>
> {
> g();
> function f() { ... x ... g ... g() ... }
> f();
> var t = some_runtime_type;
> const x:t = "inner";
> function g() { ... x ... }
> g();
> f();
> }
>
> B2 is bad because then the x inside g would sometimes refer to "outer" and sometimes to "inner".
>
> A1 and A2 introduce extra complexity but doesn't solve the problem.
I already suggested a solution to the problem based on a refinement of A1:
<http://www.mail-archive.com/es-discuss@mozilla.org/msg00899.html>
That solution is entirely compatible with runtime types. The same
identifier can be declared with different types in different parts of
a block, and each reference to it uses the one that is textually in
scope, so there is no need to check compatibility of types.
--
David-Sarah Hopwood
More information about the Es-discuss
mailing list