W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2012

Re: ECMAScript and chaining

From: Alex Russell <slightlyoff@google.com>
Date: Thu, 22 Nov 2012 14:08:11 +0000
Message-ID: <CANr5HFUaj1zj_rb-4A1DLYM_9xqq-6vD+woXLUvhuvfZ0bGxLw@mail.gmail.com>
To: Rick Waldron <waldron.rick@gmail.com>
Cc: Anne van Kesteren <annevk@annevk.nl>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On Thu, Nov 22, 2012 at 2:31 AM, Rick Waldron <waldron.rick@gmail.com>wrote:

>
>
>
> On Wed, Nov 21, 2012 at 5:26 PM, Anne van Kesteren <annevk@annevk.nl>wrote:
>
>> Hi,
>>
>> I was wondering if the plan of TC39 is to start returning the object
>> on which a method was invoked if that method would otherwise just
>> return undefined. E.g. this seems to be what Object.freeze() and
>> Object.preventExtensions() do. It's also a somewhat popular API idiom
>> in jQuery and the like (see also method chaining, fluent interface).
>>
>
> I'm not sure what you mean by "start"—this is already the prevailing
> practice. APIs either return an expected specified value/object, the target
> object (in the case of static built-ins, eg. Object.freeze(o); // o ) or a
> new specified object (eg. Array.prototype.{ filter, map } etc.).
>
>
>
>>
>> (The reason I'm asking is that I just WONTFIXED two bugs asking for
>> that stating that ECMAScript did not have this pattern either and I
>> was confronted with the above.
>
>
> Links?
>
>
>> I had been looking at Map.set()
>> myself.)
>>
>
> The ES6 Map, Set and WeakMap API specifications are still in development
> and probably shouldn't be used to make decisions like this.
>
> In this particular case there is no rationale documented for these not
> returning the object they are called from, so it's still open for
> discussion, ie. Map.prototype.set, Set.prototype.add and
> WeakMap.prototype.set.
>

Perhaps we can knock this out quickly at the next meeting?
Received on Thursday, 22 November 2012 14:09:08 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:08 UTC