Re: new

Tue, 11 Oct 2011 15:29:15 -0700

Point.zero = function () {
  return (new Point).{ x: 0, y: 0 };
}

why are factory methods special? they are just methods.

On Oct 11, 2011 11:26 PM, "Axel Rauschmayer" <[email protected]> wrote:

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 Verbate...

--  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