Re: an idea for replacing arguments.length

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