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

[WebIDL] Proposing changes to overload resolution behavior

From: Kyle Huey <me@kylehuey.com>
Date: Mon, 10 Oct 2011 10:20:35 -0400
Message-ID: <CAP045AqgkS=9e29YTFryrC3OiG-fsKaMAprySoNuNWj3_snWPA@mail.gmail.com>
To: public-script-coord@w3.org
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

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