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

Rick Waldron waldron.rick at gmail.com
Thu Dec 6 09:38:33 PST 2012


On Thu, Dec 6, 2012 at 6:53 AM, Andreas Rossberg <rossberg at google.com>wrote:

> On 6 December 2012 05:05, Rick Waldron <waldron.rick at gmail.com> wrote:
> > Again, I reject the notion that "someone might screw up" is a valid
> argument
> > for this, or any, discussion. It's one thing to be aware of the potential
> > for misuse, but entirely another to succumb to "fear driven design".
>
> "Fear driven design" is pejorative.


I'll own that, my apologies.


> The argument really is about the
> ability to do local reasoning as much as possible, which is a *very*
> valid concern, especially when reading somebody else's code using
> somebody else's library.
>
> I agree with other voices in this thread that in general, returning
> 'this' rather is an anti pattern.


The evidence I've brought to this discussion shows that the most widely
used and depended upon libraries heavily favor the pattern.



> You can get away with it if you
> limit it to very few well-known library functions,


We established a criteria for built-ins, I don't think we should be using
"return this" by default, but indeed we should where it will be an
expressive benefit.

https://gist.github.com/4219024


> but I doubt that
> blessing such style in the std lib does help that cause.
>
> /Andreas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121206/e600dc9a/attachment.html>


More information about the es-discuss mailing list