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

Rick Waldron waldron.rick at gmail.com
Wed Dec 5 20:05:34 PST 2012

On Wed, Dec 5, 2012 at 10:33 PM, Bill Frantz <frantz at pwpconsult.com> wrote:

> On 12/5/12 at 1:50 AM, jussi.kalliokoski at gmail.com (Jussi Kalliokoski)
> wrote:
>  I personally think returning `this` in absence of any meaningful value
>> (and
>> chaining in general) is a bad pattern.
> </lurk>
> I have to agree with Jussi here. Whenever I consider chaining using the
> returned values from the various things called, my programming paranoia
> hair stands on end. Let me try to explain:
> Whenever I program, I try to trust as little code as possible. With
> chaining, there are two possibilities for getting the wrong answer in the
> returned value:
>   * I or someone else wrote it, but screwed up,
>   * Someone hostile wrote it and is trying to trip me up.
> If there is a language construct that allows chaining -- like the Pascal
> "with" construct -- then I am only trusting the language*, not other
> fragments of programs. If I depend on things I call returning the correct
> "this", then I am depending on them and my dependency set is a lot larger.
> A larger dependency set makes me nervous.
> Cheers - Bill
> * For the really paranoid, minimizing the parts of the language depended
> on is important. Not all JS implementations behave the same way in the
> corner cases.

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121205/1cfdcf7e/attachment-0001.html>

More information about the es-discuss mailing list