Re: new

Tue, 11 Oct 2011 15:26:08 -0700

I absolutely love it for its conceptual beauty, but the primary goal should be 
to establish a single dominant way of doing inheritance in JavaScript.

One feature that doesn’t yet fit into my "pure OO" universe are factory 
functions/methods (I used frequently used factory methods in Java):
1. They give better names to constructors.
2. They allow one to return an instance of a subclass.

Example of #1: new Point.zero()
Example of #2: Expression.parse()

How would you add that to JavaScript?

On Oct 12, 2011, at 0:12 , Allen Wirfs-Brock wrote:

> 
> On Oct 11, 2011, at 1:46 PM, Jake Verbaten wrote:
> 
>> Yes the prototypes are still there. But that means im just using es3 
>> constructs. Es:harmony class literals only offer declarative sugar.
>> 
>> I'm not proposing we change any of the existing Class.prototype.* code. I 
>> just propose that rather then throwing an error on new <Object> we make it 
>> work.
>> 
>> This basically means we have three constructs for doing "classes". we can 
>> even have declarative desugar to prototypes as classes, but thats optional.
>> 
>> We basically give people more choice. I'd say it's worth implementing merely 
>> for having classes desugar to something with a more sensible 1<->1 mapping.
>> 
> I agree that  new <object> would be a useful feature for ES developers who 
> want to create prototypal inheritance based abstractions.   And along with 
> super support in ES.next it really enables true self-style programming.
> 
> However, I think that talking about such abstractions as "classes" creates 
> confusions and a unwarranted sense of competition with class declarations.  t 
> isn't an either/or situations where we have to choose between primitive 
> compositional operators or declarative syntax for the most common class 
> abstraction patterns.
> 
> ES objects, new <object>, new <function>, object literals, <|, and .{ would 
> provide a core set of primitives that can be used support of metaprogramming 
> implementations of a wide spectrum of object abstraction and composition 
> models. This is a good think and arguably an important aspect of using ES as 
> the foundation language of the web platform.  
> 
> Allen

-- 
Dr. Axel Rauschmayer

[email protected]
twitter.com/rauschma

home: rauschma.de
blog: 2ality.com



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

Reply via email to