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

Re: an idea for replacing arguments.length

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Mon, 11 Nov 2013 14:15:50 -0500
Message-ID: <52812CE6.1040005@mit.edu>
To: Allen Wirfs-Brock <allen@wirfs-brock.com>
CC: es-discuss@mozilla.org, "public-script-coord@w3.org" <public-script-coord@w3.org>
On 11/11/13 1:37 PM, Allen Wirfs-Brock wrote:
> My, perhaps more radical, recommendation would be to only do overloading based upon argument counts and to treat all type overloads for a given argument length as union types that are left to a function's implementation to discriminate.

We could do that, in fact; the problem becomes how to handle the few 
cases I listed in my mail.

> pretty much eliminate the idea that WebIDL based methods must be exotic objects with distinctive [[Call]] behavior.

I don't see how it changes anything in this regard, actually.

> Also, I would outlaw (new) overloads like
>
> Document:
>   TouchList createTouchList(Touch... touches);
>   TouchList createTouchList(sequence<Touch> touches);

Sure.  This one is fallout from the spec changing from one of those to 
the other but people not wanting to break compat so supporting both... 
I don't think anyone _likes_ to create an API like that.

>      var a = new Array(1,2,3);  //create a three element array with with elements initialized to 1,2,3
>      var b = new Array(1); //create a sparse array whose length is set to 1;

This is actually a different pattern from the createTouchList one above, 
though I agree it's equally undesirable.

-Boris
Received on Monday, 11 November 2013 19:16:19 UTC

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