Re: [WebIDL] Handling undefined in Overload Resolution Algorithm

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... ;)

> What does null mean as the second argument?  Use no context at all?

That's one of the things that needs to be specced here.

For what it's worth, consider the following code:

   elem.querySelector(str, x.firstChild)

If "x" has no firstChild, can you tell whether this will pass null or 
undefined, without knowing whether x happens to be a Node, etc?

If the argument is that we don't want to magically use |elem| as the 
context if there happens to be no firstChild property on x, then it 
would make sense to make both undefined and null use no context.  But 
then passing undefined needs to not have the same behavior as passing 
only one argument.

On the other hand, if we require that undefined and only one argument 
act the same, then either passing undefined and null behave differently, 
or both use |elem| as the context, which is a slightly weird thing to do 
when someone tried to explicitly pass a different scope in....

That's about the state of things so far; Jonas and I can't decide which 
of these options is worse.  ;)

-Boris

Received on Wednesday, 20 July 2011 01:53:48 UTC