(Map|Set|WeakMap)#set() returns `this` ?

Brendan Eich brendan at mozilla.org
Tue Dec 4 11:03:57 PST 2012


Allen Wirfs-Brock wrote:
> It's less clear which is the best choice for JS.

I have to say I think Mark is on the better track (not to say "only 
right track"). Cascading wants its own special form, e.g., Dave's 
mustache-repurposed proposal at

https://blog.mozilla.org/dherman/2011/12/01/now-thats-a-nice-stache/

so one can write cascades without having to be sure the methods involved 
follow an unchecked |this|-returning convention.

This frees the set return value pigeon-hole to be what many people 
naturally want, from Smalltalk to JS (just citing experience). In the 
meeting, I heard |this|-return asserted as a dominant pattern, but I 
don't believe it is -- especially not for collection.set() methods.

/be


More information about the es-discuss mailing list