Re: A variation of Allen’s Class Definition Pattern

Brendan Eich brendan at
Sun Sep 25 20:18:33 PDT 2011

On Sep 25, 2011, at 7:52 PM, Axel Rauschmayer wrote:

> I like the Class Definition Pattern and tried to make it more flexible:
>     const className = superClass <| function(/*constructor parameters */) {
>         //constructor body
>         super.constructor(/*arguments to super constructor */);
>         this.{
>          //per instance property definitions
>         };
>     }.withPrototype({
>         //instance properties defined on prototype
>     }).withProperties({
>         //class (ie, constructor) properties
>     });
> - Approach: Define two methods Function.prototype.withPrototype() and Function.prototype.withProperties(). The latter task could also be performed via the object extension operator – I used a method for reasons of symmetry. Both methods return "this".
> - Advantages compared to using the object extension operator:
>     - Can omit the class property definition (without having to append ".constructor").
>     - Both “clauses” can be swapped.

It's hard to object. The problem is that this requries a library (whether standardized into built-ins or not), and it is imperative as all get-out.

I still think class syntax has a place, but it has to be super-sweet, no verbose syntax gaffes or near-misses or brushes-with-greatness-that-landed-on-merely-good. We ain't there yet.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list