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

Re: [WebIDL] Handling undefined in Overload Resolution Algorithm

From: Jonas Sicking <jonas@sicking.cc>
Date: Thu, 21 Jul 2011 15:38:16 -0700
Message-ID: <CA+c2ei-noXL_-na=eyAd0WLE3S=yny4st05e=Z5hTjh9cKMFOw@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: public-script-coord@w3.org
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

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:04 UTC