Re: [WebIDL] Handling undefined in Overload Resolution Algorithm

On Tue, Jul 19, 2011 at 10:32 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 7/19/11 1:06 PM, Jonas Sicking wrote:
>>
>> On Tue, Jul 19, 2011 at 6:04 AM, Lachlan Hunt<lachlan.hunt@lachy.id.au>
>>  wrote:
>>>
>>> Hi,
>>>  Refer to discussion in a Mozilla bug 648722 [1].
>>>
>>> When undefined in passed to an overloaded function, the overload
>>> resolution
>>> algorithm should not exclude nullable non-primitive types.
>>
>> I'm not quite sure I understand what you are suggestion. Are you
>> saying that we should treat undefined as null when calling a function
>> that takes a nullable type?
>
> That's the proposal, yes.  This is already true if the nullable type is
> something like |String?|, but not if the nullable type is |Node|.  The
> proposal is to make is to passing |undefined| where an interface type is
> expected behaves the same as passing null (as opposed to throwing
> immediately because no overload is found).

That would work for me. So with the interface

interface Foo {
  void func(in DOMString a, in Node? b);
  void func(in DOMString a);
};

the following code:

myfoo.func("hello", undefined);

will call the first func-function. Right?

/ Jonas

Received on Tuesday, 19 July 2011 19:03:18 UTC