An "extend" operator is a natural companion to <|

Brendan Eich brendan at mozilla.com
Tue Jul 19 12:10:49 PDT 2011


On Jul 19, 2011, at 11:39 AM, Allen Wirfs-Brock wrote:

> Ok,  I did a side-by-side comparisons of some alternatives.  Seehttp://wiki.ecmascript.org/lib/exe/fetch.php?id=harmony%3Aspecification_drafts&cache=cache&media=harmony:protooperator_alternatives.pdf 
> 
> The first column is by prototypal inheritance example using<| and <& from the first message in this thread.
> 
> The second column is the same example with <| and <& replaced by keyword operators "prototypes" and "extendBy".

Nit-pick here, but: No! Never camelCaps in keywords. Consider instanceof.

Please try another word, perhaps "copies".

> The third column uses Object.specialize and Object.extend calls instead of <| and <&.
> 
> Note that Object.create can't be used instead of Object.specialize because I want the second argument to be a regular object literal rather than a property descriptor.

"specialize" is ambiguous with respect to copying vs. delegating. How about Object.delegate(to, from)? Or Object.clone, a Self homage?

It's hard to love the keyword forms, and many clearly choke on the punctuator stew. That plus the "usable from downrev scripts" lends weight to Object.{clone,extend}.

/be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110719/b7ae0173/attachment.html>


More information about the es-discuss mailing list