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

> http://wiki.ecmascript.org/doku.php?id=harmony:object_extension_literal_class_pattern
> 
> 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.

/be

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

Reply via email to