Summary: prototypes as classes

Axel Rauschmayer axel at rauschma.de
Wed Jun 29 14:24:53 PDT 2011


> That's all neat in a kind of desugaring ftw, nerdcore way, but tl;dr -- users don't care and they want to write new C and have it just work (mostly; granted some crack the code, for a few good and bad purposes).

Note that I am arguing from the perspective of a language that only has PaCs, versus a language that only has constructor functions. If you don’t, then we don’t disagree.

You argue that constructor functions are more intuitive at the user level (to *all* people) and that PaCs wouldn’t “just work” and that’s what I disagree with.

With either new Constructor(x,y) or with new Prototype(x,y) there are things you leave out (abstract away from). It is a matter of preference what those things should be:

(1) let o = new Constructor(x,y): hides/obscures the fact that the new instance has the prototype Constructor.prototype.
(2) let o = new Prototype(x,y): hides the fact that method constructor() is called.

> Anyway, the die was cast long ago.

I agree that this might be one of those cases where the cost of breaking compatibility is not worth the benefits (especially if we even can’t agree that there are benefits ;-)

-- 
Dr. Axel Rauschmayer

axel at rauschma.de
twitter.com/rauschma

home: rauschma.de
blog: 2ality.com





More information about the es-discuss mailing list