ES6 doesn't need opt-in

Axel Rauschmayer axel at rauschma.de
Fri Jan 6 03:11:15 PST 2012


>> Ok, is there any observable difference between what you would have future browsers do, vs the equivalent mechanisms except that program #2 is categorized as an ES6 program and processed as such?
>> 
>> If there is no observable difference, good. Then it's only a matter of how we describe an agreed semantics. If there is an observable difference, how is this not three modes?
> 
> There should be no observable difference.  But the issue isn't how we described the (program) semantics.  It is how we decide which semantics to apply.
> 
> The tricky cases are thing like:
> 
> function f(a) {
>     arguments[0]=2;
>     return a
> }
> print(f(1));  //2 if ES5, 1 if ES6
> 
> There is nothing in the source file that implies which specification to apply so for backwards computability a browser must default to interpreting such program as a ES5 program. Anything syntactically unique to ES5 (eg, use of a with statment) or ES6 (eg, use rest or spread) would force one interpretation or another

But what you are saying is that ES6 is not a superset of ES5.strict, right?

I thought that there were only 2 semantics:
  1.  ES5.non-strict (which is a superset of all previous versions) [a.k.a. "non-strict"]
  2.  ES6 (which is a superset of ES5.strict) [a.k.a. "strict"]

My understanding is that #1 would be the default and when one encounters anything ES6-specific (an “ES6 trigger”) or "use strict" then the semantics switches to #2.
=> encountering a with statement would be fine, because #1 is the default, anyway.
=> encountering a with statement and either an ES6 trigger or a "use strict" would be an error.

As a human, I would want an ES6 trigger to appear as early as possible. I wouldn’t want to read through a file, encounter an ES6 trigger at the end and then have to revise the understanding of the code that I had so far. I like the whole-file-or-nothing approach for switching semantics that you proposed.

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120106/7ec2bc2b/attachment-0001.html>


More information about the es-discuss mailing list