W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2016

RE: URLSearchParams: calling .set() and .append() should return itself

From: Domenic Denicola <d@domenic.me>
Date: Mon, 29 Feb 2016 12:56:11 +0000
To: Marcos Caceres <marcos@marcosc.com>, public-script-coord <public-script-coord@w3.org>
Message-ID: <CY1PR0501MB1369574B3178B0FBDB03B298DFBA0@CY1PR0501MB1369.namprd05.prod.outlook.com>
From: Marcos Caceres [mailto:marcos@marcosc.com] 

> Could I kindly ask for some clarification or a pointer from TC-39 members? If not returning the object, is there a new pattern?

I think it would be more accurate to say the pattern is contentious among TC39 members. I think it's terrible; it violates basic software engineering principles like command-query separation [1] in order to save a few characters of typing.

However, my guess would be that future collection classes designed by TC39 will continue this tradition, simply for consistency. This is similar to many other contentious decisions that we will probably carry forward forever, like adding a `thisArg` to all collection map/filter/reduce/etc. methods, or ensuring that all forEach callbacks always get three arguments even when it makes no sense (like for Set).

So it might be appropriate for URLSearchParams.

[1]: https://en.wikipedia.org/wiki/Command%E2%80%93query_separation

Received on Monday, 29 February 2016 12:56:43 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:25 UTC