Re: [WebIDL] Handling undefined in Overload Resolution Algorithm

On 7/19/11 7:24 PM, Lachlan Hunt wrote:
> Pretending for a moment that querySelector isn't an overloaded function,
> and say it only included the definition with the sequence<Null>? parameter:
>
> Element querySelector(in DOMString selectors, in sequence<Node>? refNodes);

More precisely:

Element querySelector(in DOMString selectors,
                       in optional sequence<Node>? refNodes);

> Passing undefined to that function, according to the current
> requirements in the WebIDL draft, the JS values of undefined and null
> are both converted to IDL null values in the ECMAScript to IDL
> conversion algorithm for nullable types.

One question is whether this is a conversion that makes sense for 
optional arguments...

Another question is what the behavior of the method should then be if 
the IDL null value is passed for the second argument.

> Regardless of whether that's the best handling of undefined for nullable
> types, the issue that needs to be resolved, however, is that because the
> method is actually overloaded (the other alternative accepting an
> optional Element node), the overload resolution algorithm in WebIDL
> picks neither and, I believe, throws an exception, which is very
> undesirable.

This is a third question, yes, unrelated to the above two.  I think we 
all agree that it needs to be resolved.

-Boris

Received on Wednesday, 20 July 2011 01:44:20 UTC