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

Andreas Rossberg rossberg at google.com
Thu Dec 6 03:53:52 PST 2012


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. 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. You can get away with it if you
limit it to very few well-known library functions, but I doubt that
blessing such style in the std lib does help that cause.

/Andreas


More information about the es-discuss mailing list