Readability or library preference aside, I still think it's bizarre that map.set(key, val)
is analogous to (dict[key] = val, dict) and not to dict[key] = val When I'm using a fluent library like jQuery or a configuration DSL like those in the npm packages surveyed, I can see the attraction of chaining. But when I am using a basic primitive of the language, I expect uniformity across primitives. ________________________________________ From: [email protected] [[email protected]] on behalf of Tab Atkins Jr. [[email protected]] Sent: Wednesday, December 05, 2012 14:57 To: Mark S. Miller Cc: [email protected] Subject: Re: (Map|Set|WeakMap)#set() returns `this` ? On Wed, Dec 5, 2012 at 10:04 AM, Mark S. Miller <[email protected]> wrote: > On Wed, Dec 5, 2012 at 1:50 AM, Jussi Kalliokoski > <[email protected]> wrote: >> My 2 cents against the windmills... >> >> I personally think returning `this` in absence of any meaningful value (and >> chaining in general) is a bad pattern. Chaining leads to worse readability >> (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, it's >> bad readability) > > This is an excellent point, and has changed my mind. I return to not > supporting the "return this" for these cases. Thanks. The readability of chaining *is* very subjective. I find it perfectly readable. Andrea and a few others feel strongly about this, and I respect that. But most JS libraries have gone the other way, and authors in general seem to like that direction. This constitutes pretty clear evidence about which pattern JS devs en masse prefer, and we shouldn't pretend like we know better than them. In the absence of technical problems that doom a solution, let's vote with the herd. ~TJ _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

