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

Re: Reconciling handling of optional arguments and handling of default values across ES and webidl

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Tue, 10 Sep 2013 12:18:46 -0400
Message-ID: <522F4666.30909@mit.edu>
To: Cameron McCormack <cam@mcc.id.au>
CC: Allen Wirfs-Brock <allen@wirfs-brock.com>, Brendan Eich <brendan@mozilla.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On 6/24/13 3:50 AM, Cameron McCormack wrote:
> Boris, when you're able to, review of these changes would be appreciated.
>
> http://dev.w3.org/cvsweb/2006/webapi/WebIDL/Overview.xml.diff?r1=1.628;r2=1.629;f=h

Sorry it took me so long to get to this.

Substantive comments:

1)  In the new setup, I believe this is valid IDL:

   void foo(optional long arg1, long arg2);

Is this purposeful?  It looks at first glance like this function should 
have length 2, since in 
http://dev.w3.org/2006/webapi/WebIDL/#dfn-effective-overload-set step 
5.7 we'll start with i == 1 and discover that "argument i of X" (does it 
mean "X's argument at index i"?) is not optional, so the shortest 
element of the overload set will have two arguments, right?

2) I'm not convinced about the changes to the variadic handling.  In 
particular, consider this function:

   void foo(long... argList);

and an invocation of it like so:

   foo(5, undefined, 6);

when the effective overload set is computed for this call, we get the 
following tuples:

   <foo, (long), (true)>
   <foo, (), ()>
   <foo, (long, long), (true, true)>
   <foo, (long, long, long), (true, true, true)>

then we remove all but the last entry from the list.  Now we start doing 
the argument conversions and invoke the callee with the values 5, 
|special value "missing"|, 6.

That seems pretty odd to me.  Are there use cases for having missing 
variadic args?  If not, I'd prefer we keep the old behavior, where all 
the variadics (except perhaps trailing undefined, which would simply not 
be passed on to the callee?) are coerced to the right type.   Otherwise 
we have to fix all specs using variadics to deal with the "missing" case...

3)  I don't understand step 10.2 of the overload resolution algorithm. 
Why is this needed, exactly?

Nits:

4) There is a typo in "followed only be optional arguments" when talking 
about dictionary types.

5) In the above discussion of overload sets for functions with 1 
variadic argument, I assumed that when n == 1, t_{0...n-2} means "empty 
list".  It might be worth being more explicit about that somehow... Note 
that this empty list would be added by effective overload set step 5.8 
anyway, so there is no harm in restricting step 5.5.1 to the case when n 
 > 1.

-Boris
Received on Tuesday, 10 September 2013 16:19:19 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:50 UTC