why not "new" instead of "constructor"?

Axel Rauschmayer axel at rauschma.de
Sat Nov 19 11:34:35 PST 2011

True. A method automatically does the right thing where it matters, anyway.

It’s nice to see the two concerns instantiation and initialization separated with the new() method. IIRC, the problem with subclassing Date is that it doesn’t separate them(?) If I’m right, an init() method would solve the problem. If not, can I read up on what the problem is?



On Nov 19, 2011, at 19:33 , Allen Wirfs-Brock wrote:

> On Nov 19, 2011, at 9:54 AM, Axel Rauschmayer wrote:
>> I like the idea of replacing the method name “constructor” with something better, but “new” suggests instantiation *and* initialization to me. Is “init” a possibility?
> Is that distinction between instantiation and initialization very important for the average JS programmer (or stated another way, is the average JS programmer at risk if they fail to understand that distinction).  Is the sophisticated JS programmer who understand the difference between instantiation and initialization and the detailed semantics of the new operator going to get confused it the initialization code is labeled with "new"?
> My intuition in both cases is that the answer is no.  If I'm correct then "new" seems like the better alternative.
> Allen

Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111119/d6021843/attachment-0001.html>

More information about the es-discuss mailing list