I've been concerned about the schedule risk of classes for ES.next; following 
are some thoughts about a minimal class feature that I believe satisfies the 
most important needs while leaving room for future growth.

I think the bare-minimum requirements of classes would be:

- declarative class expressions
- declarative constructor/prototype inheritance (i.e., the extends clause)
- super-calls
- declarative methods

Examples:

    class C {
        constructor(x, y) {
            this.x = x;
            this.y = y;
        }
        foo() {
            return this.x + this.y;
        }
    }

    class D extends C {
        constructor() {
            super(0, 0);
        }
        bar() {
            print("hi")
        }
    }

I suggest that for ES.next, we completely leave out declarative properties, 
class properties, or even private data. All of this can be expressed already 
with imperative features. (Private data can be implemented with private names, 
and I've come to believe that Object.freeze just simply shouldn't freeze 
private properties.) That's not to say that these features would never be 
desirable, but we've so far struggled to come up with something that hangs 
together. And the features I describe above don't close off these 
possibilities. I want classes to succeed for ES.next, and even more importantly 
I want ES.next to succeed and succeed *on time*.

I'd argue that the minimal feature set described above covers the most 
important needs:

- standardizing prototype hierarchies (I'm of the opinion that superclass 
constructors ought to be the prototype of subclass constructors in order to 
inherit class properties)
- providing declarative syntax for initializing the C.prototype object
- providing idiomatic syntax for calling the superclass constructor
- enabling instance-private and/or class-private data (via private names)

Dave

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to