Personally I'd ask whether there is a good reason to have "class" properties
on the constructor.

//class (ie, constructor) properties

You could have them on the prototype instead and then you can access these
class properties through all your instances.

Also you could just re-order the assignment like so :

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

On Sun, Oct 30, 2011 at 12:34 AM, Axel Rauschmayer <a...@rauschma.de> wrote:

>
> http://wiki.ecmascript.org/doku.php?id=harmony:object_extension_literal_class_pattern
>
>    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
>    };
>
> The main problem is that obj.prototype.{...} does not evaluate to obj, then
> one could chain additions to the function. With custom Function.prototype.*
> methods, that can be easily achieved:
>
>    const className = superClass <| function(/*constructor parameters */) {
>        //constructor body
>        super.constructor(/*arguments to super constructor */);
>        this.{
>         //per instance property definitions
>        };
>    }.proto({
>        //instance properties defined on prototype
>    }).class({
>        //class (ie, constructor) properties
>    });
>
> But what if one could write a function like an object literal?
>
>    const className = superClass <| function {
>        (/*constructor parameters*/): {
>            //constructor body
>            super(/*arguments to super constructor*/);
>            this.{
>                //per instance property definitions
>            };
>        },
>        prototype: {
>
>        }
>        //class (ie, constructor) properties
>    };
>
> --
> Dr. Axel Rauschmayer
> a...@rauschma.de
>
> home: rauschma.de
> twitter: twitter.com/rauschma
> blog: 2ality.com
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to