Re: [WebIDL] Handling undefined in Overload Resolution Algorithm

On Tue, Jul 19, 2011 at 6:53 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 7/19/11 7:53 PM, Allen Wirfs-Brock wrote:
>>
>> elm.querySelector(myself, undefined)  and elm.querySelector(myself) are
>> borderline indistinguishable from the perspective of elm.querySelector if it
>> was implemented as an ECMAScript function.  Assume that such a function is
>> defined as:
>
> Well, if you don't check arguments.length, as you point out.  Just like in
> the C++ implementation of this, actually... ;)

Indeed. One way to look at the posed question here is: Are JS
developers more used to code checking arguments.length, or looking for
which arguments have the value <undefined>?

My impression is that Allen is saying that the latter is more common in JS land.

This raises another interesting question. For a function like:

  void func(optional in DOMString param2);

What should we do for code like:

o.func(undefined);

Should that behave like

o.func();

or

o.func("undefined");

I believe the spec currently says the latter, but Allen's argument
would indicate that the former is what developers would expect?

This is something that has actually come up. [1] shows one site
breaking over expecting the former behavior when Firefox implemented
the latter.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=605296

/ Jonas

Received on Thursday, 21 July 2011 22:39:15 UTC