ES6 plans: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Created page with "== Harmony infrastructure == * New SM version number * Opt-in via type="text/ecmascript;version=6" or whatever - [https://bugzilla.mozilla.org/show_bug.cgi?id=694107 bug 694107]...")
 
(caroline marked obsolete)
 
(17 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Harmony infrastructure ==
{{OutdatedSpiderMonkey}}


* New SM version number
== New and improved builtin APIs ==
* Opt-in via type="text/ecmascript;version=6" or whatever - [https://bugzilla.mozilla.org/show_bug.cgi?id=694107 bug 694107]
* Per-script opt-in syntax ('use harmony;' or whatever)
* Opt-in via HTTP header?
* Whole-page opt-in via HTML feature?


== Modules ==
Most of this stuff does not need to touch a lot of code. None of it requires a Harmony opt-in. This is great stuff for new contributors to start work on.
 
[http://wiki.ecmascript.org/doku.php?id=harmony:modules harmony:modules]
 
Modules are [https://bugzilla.mozilla.org/show_bug.cgi?id=568953 bug 568953].
 
* <code>module</code> syntax, scoping semantics, module objects
* <code>import</code> syntax
* <code>from "url"</code> syntax
* Hook up <code>from "url"</code> and async module loading to Gecko
* [http://wiki.ecmascript.org/doku.php?id=harmony:module_loaders Module loaders]
 
 
== New APIs that are in modules ==
* [http://wiki.ecmascript.org/doku.php?id=harmony:modules_standard Reorganize the standard library into modules]
* [http://wiki.ecmascript.org/doku.php?id=harmony:private_name_objects Private name objects] - [https://bugzilla.mozilla.org/show_bug.cgi?id=694127 bug 694127]
* A few functions for [http://wiki.ecmascript.org/doku.php?id=harmony:iterators iterating over object properties]
 
 
== New builtin APIs ==
 
Most of this stuff does not need to touch a lot of code. Pretty good fodder for newbies.


* [http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets Simple Maps and Sets] - The spec is incomplete but I will be landing what's there now in [https://bugzilla.mozilla.org/show_bug.cgi?id=697479 bug 697479].
* [http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets Simple Maps and Sets] - The spec is incomplete but I will be landing what's there now in [https://bugzilla.mozilla.org/show_bug.cgi?id=697479 bug 697479].
* [http://wiki.ecmascript.org/doku.php?id=harmony:binary_data Binary data] - [https://bugzilla.mozilla.org/show_bug.cgi?id=578700 bug 578700]
* [http://wiki.ecmascript.org/doku.php?id=harmony:binary_data Binary data] - [https://bugzilla.mozilla.org/show_bug.cgi?id=578700 bug 578700]
* New reflection methods [http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api Object.getPropertyDescriptor, Object.getPropertyNames]
* New reflection methods [http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api Object.getPropertyDescriptor, Object.getPropertyNames]
* Two more methods are proposed here: [strawman:extended_object_api http://wiki.ecmascript.org/doku.php?id=strawman:extended_object_api]
* Number.[http://wiki.ecmascript.org/doku.php?id=harmony:number.isfinite isFinite], [http://wiki.ecmascript.org/doku.php?id=harmony:number.isnan isNaN], [http://wiki.ecmascript.org/doku.php?id=harmony:number.isinteger isInteger], and [http://wiki.ecmascript.org/doku.php?id=harmony:number.tointeger toInteger]
* Number.[http://wiki.ecmascript.org/doku.php?id=harmony:number.isfinite isFinite], [http://wiki.ecmascript.org/doku.php?id=harmony:number.isnan isNaN], [http://wiki.ecmascript.org/doku.php?id=harmony:number.isinteger isInteger], and [http://wiki.ecmascript.org/doku.php?id=harmony:number.tointeger toInteger]
* String.prototype.[http://wiki.ecmascript.org/doku.php?id=harmony:string.prototype.repeat repeat], [http://wiki.ecmascript.org/doku.php?id=harmony:string_extras startsWith, endsWith, contains, toArray]
* String.prototype.[http://wiki.ecmascript.org/doku.php?id=harmony:string.prototype.repeat repeat], [http://wiki.ecmascript.org/doku.php?id=harmony:string_extras startsWith, endsWith, contains, toArray]
* New reflection API that complements proxies: [harmony:reflect_api http://wiki.ecmascript.org/doku.php?id=harmony:reflect_api]
* New reflection API that complements proxies: [http://wiki.ecmascript.org/doku.php?id=harmony:reflect_api harmony:reflect_api]
* [http://wiki.ecmascript.org/doku.php?id=harmony:egal Object.is, isnt]
* [http://wiki.ecmascript.org/doku.php?id=harmony:egal Object.is]
* [http://wiki.ecmascript.org/doku.php?id=harmony:more_math_functions More math functions] - Proposed are: Math.log10, log2, log1p, expm1, cosh, sinh, tanh, acosh, asinh, atanh, hypot, trunc, sign; perhaps gamma and erf; and perhaps randomInt(n).
* [http://wiki.ecmascript.org/doku.php?id=harmony:more_math_functions More math functions] - Proposed are: Math.log10, log2, log1p, expm1, cosh, sinh, tanh, acosh, asinh, atanh, hypot, trunc, sign; perhaps gamma and erf; and perhaps randomInt(n). See [https://bugzilla.mozilla.org/show_bug.cgi?id=717379 bug 717379].
* ES6 will spec that [http://wiki.ecmascript.org/doku.php?id=harmony:random-er Math.random] does not share state across multiple globals.
 
== New syntax (stuff that affects the front end and/or bytecode) ==


This stuff isn't terribly hard either, for the most part.


== New syntax (stuff that affects the front end and/or bytecode) ==
* [http://wiki.ecmascript.org/doku.php?id=harmony:egal <code>is</code> and <code>isnt</code> operators]
* [http://wiki.ecmascript.org/doku.php?id=harmony:iterators for-of loops] - [https://bugzilla.mozilla.org/show_bug.cgi?id=699565 bug 699565] - This is I'd say better than half done. It was easy. XPConnect must be updated so that arraylike XPCOM objects cooperate with for-of.
* [http://wiki.ecmascript.org/doku.php?id=harmony:iterators for-of loops] - [https://bugzilla.mozilla.org/show_bug.cgi?id=699565 bug 699565] - This is I'd say better than half done. It was easy. XPConnect must be updated so that arraylike XPCOM objects cooperate with for-of.
* [http://wiki.ecmascript.org/doku.php?id=harmony:parameter_default_values Parameter default values]
* [http://wiki.ecmascript.org/doku.php?id=harmony:parameter_default_values Parameter default values]
* [http://wiki.ecmascript.org/doku.php?id=harmony:rest_parameters Rest parameters] - [https://bugzilla.mozilla.org/show_bug.cgi?id=574132 bug 574132]
* [http://wiki.ecmascript.org/doku.php?id=harmony:rest_parameters Rest parameters] - [https://bugzilla.mozilla.org/show_bug.cgi?id=574132 bug 574132]
* [http://wiki.ecmascript.org/doku.php?id=harmony:spread Spread operator] - [https://bugzilla.mozilla.org/show_bug.cgi?id=574130 bug 574130] - The operator can appear in two places: function calls and array literals. I think the implementation will be
* [http://wiki.ecmascript.org/doku.php?id=harmony:spread Spread operator] - [https://bugzilla.mozilla.org/show_bug.cgi?id=574130 bug 574130] - The operator can appear in two places: function calls and array literals. Maybe two bugs would make sense.
* [http://wiki.ecmascript.org/doku.php?id=harmony:proper_tail_calls Proper tail calls]
* [http://wiki.ecmascript.org/doku.php?id=harmony:proper_tail_calls Proper tail calls]
* [http://wiki.ecmascript.org/doku.php?id=harmony:object_literals Extensions to object literal syntax]
* [http://wiki.ecmascript.org/doku.php?id=harmony:object_literals Extensions to object literal syntax]
* [http://wiki.ecmascript.org/doku.php?id=harmony:classes Classes]
* [http://wiki.ecmascript.org/doku.php?id=harmony:classes Classes]
* [http://wiki.ecmascript.org/doku.php?id=harmony:quasis Quasi-literals]
* [http://wiki.ecmascript.org/doku.php?id=harmony:quasis Quasi-literals] [https://bugzilla.mozilla.org/show_bug.cgi?id=688857 Bug 688857]
* [http://wiki.ecmascript.org/doku.php?id=harmony:pragmas Pragmas]
* [http://wiki.ecmascript.org/doku.php?id=harmony:pragmas Pragmas]


== Updating SpiderMonkey extensions to the ES6 spec ==


== Updating SpiderMonkey extensions to Harmony ==
We've implemented a ton of stuff, dating back years, that is going to be in ES6 but in a slightly different form.


=== Direct proxies ===
=== Direct proxies ===


There is a ton of verbiage here and it is still under active development.
There is a ton of verbiage here and it is still under active development. Still, I think it should be pretty easy to implement. We already have the forwarding code. We can keep <code>Proxy.create</code> and <code>createFunction</code> without a lot of extra effort.
 
[https://bugzilla.mozilla.org/show_bug.cgi?id=703537 Bug 703537].


* http://wiki.ecmascript.org/doku.php?id=harmony:direct_proxies
* http://wiki.ecmascript.org/doku.php?id=harmony:direct_proxies
Line 79: Line 58:
* TC39 is specifying that reading a let-variable before it is initialized is an error, which will be a separate bug.
* TC39 is specifying that reading a let-variable before it is initialized is an error, which will be a separate bug.
* <code>const</code> - [https://bugzilla.mozilla.org/show_bug.cgi?id=611388 bug 611388]
* <code>const</code> - [https://bugzilla.mozilla.org/show_bug.cgi?id=611388 bug 611388]
* Block functions - [https://bugzilla.mozilla.org/show_bug.cgi?id=585536 bug 585536]
* Block functions - [https://bugzilla.mozilla.org/show_bug.cgi?id=585536 bug 585536] (note - opt-in only, still banned in ES5 strict mode)
* [http://wiki.ecmascript.org/doku.php?id=harmony:destructuring Destructuring]
* [http://wiki.ecmascript.org/doku.php?id=harmony:destructuring Destructuring]
* Per loop iteration binding of let/const.


=== Isolate Math.random to use per-global state ===
== Harmony infrastructure ==


* [http://wiki.ecmascript.org/doku.php?id=harmony:random-er harmony:random-er]
Some minimal steps here are a prerequisite to doing the features that require a Harmony opt-in: modules and import, block-scoped functions, <code>typeof null</code>, and lexical scoping of names declared at toplevel.


* New SM version number - This is enough to get started on harmony features with only shell tests.
* Opt-in via type="text/ecmascript;version=6" or whatever - [https://bugzilla.mozilla.org/show_bug.cgi?id=694107 bug 694107]
* Per-script opt-in syntax ('use harmony;' or whatever)
* Opt-in via HTTP header?
* Whole-page opt-in via HTML feature?
== Modules ==
[http://wiki.ecmascript.org/doku.php?id=harmony:modules harmony:modules]
Modules are [https://bugzilla.mozilla.org/show_bug.cgi?id=568953 bug 568953].
* <code>module</code> syntax, scoping semantics, module objects
* <code>import</code> syntax
* <code>from "url"</code> syntax
* Hook up <code>from "url"</code> and async module loading to Gecko
* [http://wiki.ecmascript.org/doku.php?id=harmony:module_loaders Module loaders]
With a Harmony opt-in, programs get very different global binding behavior. The bindings are no longer shared with the global object's properties. This is a major change.
== New APIs that are in modules ==
* [http://wiki.ecmascript.org/doku.php?id=harmony:modules_standard Reorganize the standard library into modules]
* [http://wiki.ecmascript.org/doku.php?id=harmony:private_name_objects Private name objects] - [https://bugzilla.mozilla.org/show_bug.cgi?id=645416 bug 645416]
* A few functions for [http://wiki.ecmascript.org/doku.php?id=harmony:iterators iterating over object properties]


== Mistakes (unnecessary breaking changes that can't be detected statically) ==
== Incompatible changes ==
Harmony may change some ES1-5 behavior, if it empirically turns out to be doable without breaking the Web.
* [http://wiki.ecmascript.org/doku.php?id=harmony:completion_reform Change how eval decides which value to return]
* [http://wiki.ecmascript.org/doku.php?id=harmony:completion_reform Change how eval decides which value to return]
* typeof null == "null" with Harmony opt-in - [https://bugzilla.mozilla.org/show_bug.cgi?id=651251 bug 651251]
* typeof null == "null" with Harmony opt-in - [https://bugzilla.mozilla.org/show_bug.cgi?id=651251 bug 651251]

Latest revision as of 22:16, 27 April 2021

Ambox outdated.png THIS PAGE IS OBSOLETE
This article is in parts, or in its entirety, outdated. Hence, the information presented on this page may be incorrect, and should be treated with due caution. Visit SpiderMonkey.dev for more up to date information.

New and improved builtin APIs

Most of this stuff does not need to touch a lot of code. None of it requires a Harmony opt-in. This is great stuff for new contributors to start work on.

New syntax (stuff that affects the front end and/or bytecode)

This stuff isn't terribly hard either, for the most part.

Updating SpiderMonkey extensions to the ES6 spec

We've implemented a ton of stuff, dating back years, that is going to be in ES6 but in a slightly different form.

Direct proxies

There is a ton of verbiage here and it is still under active development. Still, I think it should be pretty easy to implement. We already have the forwarding code. We can keep Proxy.create and createFunction without a lot of extra effort.

Bug 703537.

Generators and comprehensions

let, const, and block functions

Block scoped bindings

  • Top-level let shouldn't be the same thing as var, per dherman: bug 589199
  • TC39 is specifying that reading a let-variable before it is initialized is an error, which will be a separate bug.
  • const - bug 611388
  • Block functions - bug 585536 (note - opt-in only, still banned in ES5 strict mode)
  • Destructuring
  • Per loop iteration binding of let/const.

Harmony infrastructure

Some minimal steps here are a prerequisite to doing the features that require a Harmony opt-in: modules and import, block-scoped functions, typeof null, and lexical scoping of names declared at toplevel.

  • New SM version number - This is enough to get started on harmony features with only shell tests.
  • Opt-in via type="text/ecmascript;version=6" or whatever - bug 694107
  • Per-script opt-in syntax ('use harmony;' or whatever)
  • Opt-in via HTTP header?
  • Whole-page opt-in via HTML feature?

Modules

harmony:modules

Modules are bug 568953.

  • module syntax, scoping semantics, module objects
  • import syntax
  • from "url" syntax
  • Hook up from "url" and async module loading to Gecko
  • Module loaders

With a Harmony opt-in, programs get very different global binding behavior. The bindings are no longer shared with the global object's properties. This is a major change.

New APIs that are in modules

Incompatible changes

Harmony may change some ES1-5 behavior, if it empirically turns out to be doable without breaking the Web.

Proposals that should not create any work for us