W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2015

RE: Writing spec algorithms in ES6?

From: Domenic Denicola <d@domenic.me>
Date: Thu, 11 Jun 2015 20:50:12 +0000
To: Dimitri Glazkov <dglazkov@google.com>, public-webapps <public-webapps@w3.org>
Message-ID: <CY1PR0501MB13694D04D2EEE4A2E765B8A3DFBC0@CY1PR0501MB1369.namprd05.prod.outlook.com>
Some previous discussion: [1] especiallly [2]

In general I think this is a reasonable thing, but it requires a decent bit more infrastructure to do things “safely”. For example, consider the definition [3]. It's generic in its arguments, which I think is nice (but does not fit with Web IDL---whatever). However, it's susceptible to author code overriding Array.prototype.join. Similarly, [4] relies upon the author-modifiable Math.max and Math.min, not to mention the author-modifiable Math binding.

I go into these issues in a bit more detail in [5], although that's from an implementation perspective. Regardless, it at least opens with another good example.

If we wanted to make this feasible---and I think that would be a good thing---I think at a minimum we'd need:

- "JS bindings" for all the ES abstract operations, so you could do e.g. max(...) or DefinePropertyOrThrow(...) instead of Math.max(...) and Object.defineProperty(...)
- Some way of expressing private state in ES. (Maybe WeakMaps are sufficient, semantically, but syntactically they are awkward.)
- Some kind of Record type, as well as some kind of List type, corresponding to those in the ES spec. Trying to use just objects or arrays will fail in the face of modifications to Object.prototype and Array.prototype. (Boris goes over this in [2])

It's a decent bit of work...

[1]: https://esdiscuss.org/topic/for-of-loops-iteratorclose-and-the-rest-of-the-iterations-in-the-spec

[2]: https://esdiscuss.org/topic/for-of-loops-iteratorclose-and-the-rest-of-the-iterations-in-the-spec#content-26

[3]: http://dev.w3.org/csswg/css-color/#dom-rgbcolor-stringifiers

[4]: http://dev.w3.org/csswg/css-color/#dom-hslcolor-hslcolorrgb

[5]: https://docs.google.com/document/d/1AT5-T0aHGp7Lt29vPWFr2-qG8r3l9CByyvKwEuA8Ec0/edit#heading=h.9yixony1a18r

Received on Thursday, 11 June 2015 20:50:42 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:31 UTC