I'm probably not the first to have thought of this, but it seemed like
the most minimal class support I could think of, and it sounds like
that's where things are headed from the lack of agreement. Through the
additions made by the Set Literal Prototype operator proposal, I think
you nailed 90% of the pain point for most developers. Nicer method
syntax, simple extension functionality, and the addition of super
seals the deal. The only thing missing is how to translate that set of
functionality to work with "classes" instead of just objects. It seems
so close, in fact, that the idea of doing a class hierarchy in a
different way seems almost unintuitive.

My suggestion is simply that the <| operator get overloaded to work
slightly differently if the LHS is a "class" instead of an object. The
wiki defines the class definition pattern as:

        const className = superClass <| function(/*constructor parameters */) {
          //constructor body
          super.constructor(/*arguments to super constructor */);
          this.{
           //per instance property definitions
          };
        }.prototype.{
          //instance properties defined on prototype
        }.constructor.{
          //class (ie, constructor) properties
        };

I guess I just don't see why we can't just overload to do this instead:

        const ClassName = SuperClass <| {
                constructor(/*constructor parameters */) {
                   //constructor body
                   super.constructor(/*arguments to super constructor */);
                   this.{
                     //per instance property definitions
                   }
                }
                method1(){ return super.method1(); }
                method2(){}
                prop1:"Properties unlikely, but allowed"
        }.{
                //class properties
                staticMethod(){}
        };


That would be sugar enough for me, and I think most javascript devs.
It also means that no additional syntax is introduced beyond what
already has been added to harmony.

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

Reply via email to