Summary: prototypes as classes

Brendan Eich brendan at mozilla.com
Wed Jun 29 13:53:23 PDT 2011


On Jun 29, 2011, at 1:48 PM, Axel Rauschmayer wrote:

> Prototypes-as-classes (starting from scratch, with a clean protocol that has no notion of constructor functions):
>        new C(x,y)
> desugars (conceptually!) to
>        (new C).constructor(x,y)
> With:
> (1) Instantiation: new C
> (2) Initialization: .constructor(x, y)

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


> I find that PaCs untangle (1) and (2), because method constructor() only has to play role (2), whereas constructor functions have to sometimes play both roles, sometimes only role (2) (when called from a sub-constructor).

I see your point, but most of the time this is detail to be abstracted away from, not modeled in one's head every time one writes new C or even C().

Anyway, the die was cast long ago.

/be


More information about the es-discuss mailing list