Couldn’t #1 (optionally) be handled via a proxy and #2+#3 via static analysis?

On May 24, 2012, at 22:50 , Erik Arvidsson wrote:

> I think it is impossible to achieve Waldemar's goal with syntactic
> sugar only. I also don't think that is reason enough to block ES6
> classes. The requirements he wants cannot be expressed with ES5
> semantics.
> 
> The big issues Waldemar wanted were (as far as I remember):
> 
> 1. Reading a non existent property should throw:
> 
> const class C {}
> const c = new C;
> console.log(c.foo);  // throw to catch typos
> 
> This is a major change in semantics of JS and it was shot down for ES5
> strict so I don't think it has any chance of getting accepted ever.
> 
> 2. No way for an object to escape the constructor before the
> constructor was "done":
> 
> const class C {
>  constructor() {
>    this.x = doSomething(this);  // oops, this.y is not yet initialized
>    this.y = doSomethingElse();
> }
> 
> Alternatives here include read barriers but that also requires
> declarative instance properties so we know ahead of time what to
> poison.
> 
> 3. Shape guarantee:
> 
> const class C {
>  constructor() {
>    if (Math.random() < .5)
>      this.x = true;  // Half of the times there will not be an x property.
> }
> 
> The problems with these is that no other dynamic language has these
> kind of requirements. JS developers get by without them today. If we
> designed a new language I think they would be nice features to have
> (ahem Dart) but our goal is to improve ECMAScript and not replace it.
> We should not try to make all languages fit into the same box.
> 
> At this point I think it is up to Waldemar and supporters of his
> requirements to come up with concrete proposals how these things can
> fit into ECMAScript. (Thanks Russel for starting this thread.)

-- 
Dr. Axel Rauschmayer
[email protected]

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

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to