W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2012

Re: WebIDL overload resolution, arrays and Nullable

From: Joshua Bell <jsbell@chromium.org>
Date: Fri, 29 Jun 2012 10:12:59 -0700
Message-ID: <CAD649j5JwOQtQMMFx+rSZ7RRw21CXSLaK9AkbffnzTHV+YTT1g@mail.gmail.com>
To: public-webapps@w3.org
On Fri, Jun 29, 2012 at 9:50 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> On 6/29/12 12:25 PM, Joshua Bell wrote:
>
>> void f(float[] x); // overload A
>> void f(DOMString x); // overload B
>>
>> WebIDL itself, of course, doesn't dictate how matching and dispatching
>> should be implemented
>>
>
> Actually, it does. http://dev.w3.org/2006/webapi/**WebIDL/#dfn-overload-**
> resolution-algorithm<http://dev.w3.org/2006/webapi/WebIDL/#dfn-overload-resolution-algorithm>
>
>
Ah, thank you! I'd missed that, mired in 3.2.6. Very happy to be wrong.


> The implication is that an IDL that defines methods
>> with signatures that are not distinguishable is invalid
>>
>
> Correct.
>
>
>  So rephrasing the question: are the above types distinguishable?
>>
>
> http://dev.w3.org/2006/webapi/**WebIDL/#dfn-distinguishable<http://dev.w3.org/2006/webapi/WebIDL/#dfn-distinguishable>seems pretty clear: yes.
>
>
>  And if so, which would be expected to handle the call:
>>
>> f(null);
>>
>> Several interpretations and hence outcomes occur to us
>>
>
> Per current spec, at http://dev.w3.org/2006/webapi/**WebIDL/#dfn-overload-
> **resolution-algorithm<http://dev.w3.org/2006/webapi/WebIDL/#dfn-overload-resolution-algorithm>step 13 we have:
>
> * Substep 2 is skipped because there are no nullable types or
>  dictionaries here.
> * Substeps 3-6 are skipped because null is not an object.
> * In step 7 the overload with DOMString is selected
>
>
>  (3) T[] does not match null, but as null is an ECMAScript primitive
>> value it is run through ToString() and hence overload B is invoked with
>> DOMString "null"
>>
>
> This is what happens per spec at the moment, but the fact that null is a
> primitive value is somewhat irrelevant except insofar as it makes it not
> match the preconditions in substep 4.


Agreed and agreed, thank you.
Received on Friday, 29 June 2012 17:13:27 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:52 GMT