(Map|Set|WeakMap)#set() returns `this` ?
waldron.rick at gmail.com
Wed Dec 5 10:17:36 PST 2012
On Wed, Dec 5, 2012 at 1:04 PM, Mark S. Miller <erights at google.com> wrote:
> On Wed, Dec 5, 2012 at 1:50 AM, Jussi Kalliokoski
> <jussi.kalliokoski at gmail.com> wrote:
> > My 2 cents against the windmills...
> > I personally think returning `this` in absence of any meaningful value
> > chaining in general) is a bad pattern. Chaining leads to worse
> > (there's nothing subjective about this, if you have to scan the code to
> > another page to figure out which object the code is interacting with,
> > bad readability)
> This is an excellent point, and has changed my mind. I return to not
> supporting the "return this" for these cases. Thanks.
In the cases that we identified as qualifying for the criteria that you
established at the meeting, a "chain" will most likely only have one more
method call or property access after .set()—any of the iterable producing
methods (keys, values, entries), forEach, or the size property. But this
also now makes any operation where I want to mutate the map/set and
immediately do something with that object a two part exercise.
"some people will misuse it" can be the argument for anything, that doesn't
make it a strong or meaningful argument.
cc'ing Doug Crockford, Erik Arvidsson, Alex Russell, Yehuda Katz to weigh
in on this.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss