Re: More thoughts on Allen’s class definition pattern

Brendan Eich brendan at
Sun Oct 30 15:36:35 PDT 2011

On Oct 30, 2011, at 12:33 PM, Allen Wirfs-Brock wrote:

> The object exemplar approach is just like self or selfish, except that it builds upon features that are already in JS.  Specifically, it uses the new operator instead of a new method and it names the initialization method "constructor" in order to tie into the object construction mechanisms that already exist in JS. 


The only thing I find off the mark is the typography of <|. In light of this, and of the anti-grawlix reaction among many people, could we revisit an infix operator used in restricted productions with [no LineTerminator here] on the left of the operator contextual keyword?

Likely keywords include 'proto' (but 'protos' seems better English given the LHS being the prototype object), or my current best shot: 'beget'.

        let obj = base beget {a: 1, b: 2}
        let arr = base beget [p, q, r]
        let fun = base beget function (...args) { ... }
        let re  = base beget /(\w+)\s+(\w)+/g

It's still idiomatic as a name for differential inheritance, but it is more pithy than 'make' or 'create' (and one character shorter than 'create' -- no Unix 'creat' reruns! ;-). Comments?

Saying or writing "triangle" does not convey meaning, and it's confusing in geometry/graphics contexts.

While I still think 'class' is easier to teach, there's a risk if JS has 'class' syntax that desugars to constructors with prototypes. And with your exemplar proposal, if we're really going to level the prototype/constructor playing field, then we need more than 'new'/'constructor' protocols for objects as well as functions. We need 'beget'.


More information about the es-discuss mailing list