[WebIDL] Proposing changes to overload resolution behavior

First, my apologies if this has been brought up before, I haven't been
following this list in the past.

I have been considering how to implement WebIDL's overloading behavior in
Gecko.  There are some parts of the spec that will make this behavior quite
difficult to implement:

1. Allowing the overload resolution behavior to be specified on a
per-interface basis will require a significant amount of implementation
complexity for questionable benefit.  Rather than disambiguation behavior
for the case:

interface A {
  // ...
};

interface B {
  // ...
};

interface C {
  void f(A? x);
  void f(B? x);
};

being specified by interface C (and being arbitrarily complex!), I propose
that in any ambiguity in the overloads be resolved with whichever method is
declared first in the interface "winning".  Specs can be written to deal
with this limitation.

2. Allowing interfaces to be distinguishable solely based on interface
identity is problematic.  Consider the following:

interface A {
  // ...
};

interface B : A {
  // ...
};

interface C {
  void f(A? x);
  void f(B? x);
};

If one passes in an object implementing interface B to C::f, which overload
should be invoked?  This is problematic for us from C++ too where
determining which overload to call depends on determining the most derived
class (which is completely doable, but slow and annoying).  I propose that
we modify the definition of distinguishable interfaces to be distinct
interfaces where one interface does not lie on the inheritance chain of the
other.

- Kyle

Received on Monday, 10 October 2011 14:21:02 UTC