ES6 doesn't need opt-in

Andreas Rossberg rossberg at google.com
Thu Jan 5 06:29:38 PST 2012


On 4 January 2012 21:27, Brendan Eich <brendan at mozilla.com> wrote:
> On Jan 4, 2012, at 4:12 AM, Andreas Rossberg wrote:
>>>
>>> Your (3) seemed to say "use module" was something distinct from (and also
>>> implicit in, so a part but not the whole of what is declared by) module
>>> declaration syntax. It's not -- as proposed, it's an alternative to explicit
>>> anonymous module{...} bracketing syntax that translates the block or body
>>> enclosing the pragma to an anonymous module.
>>
>> Yes, I understand that. My point was that you can reformulate all
>> that, for (almost) equivalent effect, by saying that "use module" is
>> _not_ a module definition, but basically the same mode pragma as
>> before,
>
> Just to be clear: you mean |use version 6;| here by "mode pragma as before"?

Yes.

>> The only difference I can see with this description is its effect on
>> the semantics of multi-part scripts.
>
> Dave's proposal has
>
>   <script>
>     window.foo = "hi";
>   </script>
>   <script>
>     use module;
>     alert(foo);
>   </script>
>
> desugar to
>
>   <script>
>     window.foo = "hi";
>   </script>
>   <script>
>     module {
>       alert(foo);   // no early error, runs and alerts "hi"
>     }
>   </script>
>
> which is not the same as what we were thinking of with "no global object as
> top scope" enabled by a version pragma:
>
>   <script>
>     window.foo = "hi";
>   </script>
>   <script>
>     use version 6;
>     alert(foo);     // early error here!
>   </script>

Right. That's (part of) what I was alluding to with my above remark. ;)

/Andreas


More information about the es-discuss mailing list