On Oct 13, 2008, at 3:51 PM, Waldemar Horwat wrote:

> Brendan Eich wrote:
>> After some experiments, we decided for ES4 to make let and var the
>> same at top level in a function or global code.
>>
>> This helped avoid implementation pain: very long scripts on the web,
>> consisting of many statements in a row, motivate statement-wise
>> parsing and cumulative code generation, which is straightforward in
>> the absence of goto. Yet scope changes (e.g. due to a tardy rogue let
>> x; after thousands of statements the first of which uses x) require a
>> separate pass to generate the necessary block set-up code before the
>> first use of x.
>>
>> Unifying let and var at top level also reduces the cognitive load
>> (number of scopes in mind) and eliminates useless name shadowing
>> opportunities.
>>
>> But such let/var unification at top level in a function body does
>> leave bad old arguments[0] aliasing x in the above example, allowing
>> mutation of otherwise lexical let x; (change var to let and fill in
>> the ... with arguments[0] = 42; return x). The answer that we chose
>> for ES4, and the one that's already agreeable in committee for
>> Harmony, was "deprecate arguments by providing optional and rest
>> parameters".
>
> You can't do that.

Which "that" do you mean?


> function f() {
>  x = 15;
>  ...
>  let t = some_runtime_expression;
>  ...
>  let x:t = ...
> }
>
> What is the type of x at the beginning of the function?

The example had better fail to compile.

I hope my point about implementations optimizing for very long "AST  
hedge" programs on the web is mixed up here. Such implementations  
build a full AST for function bodies, and function bodies tend to be  
reasonably short on the web (Tennent be damned). Long global code  
consisting of repeated assignment statements, OTOH, can suck up too  
much time and space if compiled as a whole instead of incrementally.

But I still don't know which "that" you meant.

/be
_______________________________________________
Es-discuss mailing list
Es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to