Global lexical tier

saam barati saambarati1 at gmail.com
Wed Sep 2 03:04:43 UTC 2015


Thanks. Reading now.

I'm clearly bad at email :/

On Tue, Sep 1, 2015 at 7:51 PM, Rick Waldron <waldron.rick at gmail.com> wrote:

>
>
> On Tue, Sep 1, 2015 at 10:41 PM SaamBarati1 <saambarati1 at gmail.com> wrote:
>
>> Hi Allen,
>>
>> What were the requirements for the global lexical scope? Is it written
>> somewhere I can read? I came up empty after a quick search of
>> esdiscuss.org.
>>
>> I think the whole point of ES6 lexical scoping is to limit scope to
>> something you can read in a given file (or script, or block, or eval, or
>> unit of JS code). Except, this breaks down for global top-level
>> let/const/class. I argue that if you want these variables to be visible
>> across JS programs, you should be using modules. The current spec makes
>> this somewhat better than "var"s because these variables are no longer
>> properties on the global object, but it punted and said that there is some
>> magical lexical scope that wraps all programs. I think it's more in the
>> spirit of lexical scoping to have these variables be limited to the program
>> they're defined in (as if the entire program were wrapped in {}). And it's
>> more in the spirit of ES6 to share code across programs using modules.
>>
>> I think it's not helpful for you to threaten that our opinions are less
>> useful than a proof of impossibility when we are people who are both
>> interested in the JavaScript language and interested in implementing it
>> well. I've spent > 8 hours today implementing the "global lexical tier", so
>> I think it's helpful to categorize my opinion as being slightly greater
>> than "less useful than a proof that the spec is impossible to implement".
>> Sometimes the best ideas are those that are negligent of "requirements".
>>
>
> Allen already provided links to discussions of record that lead to the
> design in ES6. Those discussions capture the requirements and supporting
> rationale. Here they are again:
>
>
> https://github.com/rwaldron/tc39-notes/blob/master/es6/2012-07/july-25.md#scoping-rules-for-global-lexical-declaration
>
>
> https://github.com/rwaldron/tc39-notes/blob/master/es6/2012-09/sept-19.md#global-scope-revisit
>
>
> https://github.com/rwaldron/tc39-notes/blob/master/es6/2013-11/nov-21.md#46-the-global-scope-contour
>
>
> https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-11/nov-18.md#45-global-let-shadowing-of-global-object-properties
>
>
> plus various es-discuss threads:
> https://www.google.com/?gws_rd=ssl#q=site:http:%2F%2Fesdiscuss.org+global+let
> <https://www.google.com/?gws_rd=ssl#q=site:http://esdiscuss.org+global+let>
>
>
> Rick
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150901/66fd984a/attachment.html>


More information about the es-discuss mailing list