Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"it is not possible for a single platform object to implement both interfaces" #59

Closed
domenic opened this issue Sep 27, 2015 · 3 comments
Labels
☕☕☕ difficulty:hard Excruciating ⌛⌛ duration:medium Shouldn't be too long to fix editorial Changes that do not affect how the standard is understood.

Comments

@domenic
Copy link
Member

domenic commented Sep 27, 2015

Apparently two IDL interface types are distinguishable if all of the following hold

  • The two identified interfaces are not the same
  • It is not possible for a single platform object to implement both interfaces
  • It is not the case that both are callback interfaces.

This second condition is very confusing. I can think of two possible interpretations:

Interpretation A

[NoInterfaceObject] interface Foo {};
[NoInterfaceObject] interface Bar {};

interface Baz {};
Baz implements Foo;
Baz implements Bar;

Baz implements both Foo and Bar, so Foo and Bar are not distinguishable. (Contrapositive of the given statement.)

Interpretation B

[NoInterfaceObject] interface Foo { readonly attribute x; };
[NoInterfaceObject] interface Bar { attribute x; };

interface Baz {};
Baz implements Foo;
Baz implements Bar; // not allowed

It is not possible to implement both Foo and Bar at the same time, so they are distinguishable.

Discussion

Both of these interpretations kind of suck.

Interpretation A is a very nonlocal definition. To determine if A and B are distinguishable, you have to look at all interfaces in the web platform, and find out if any of them implement both A and B. (I think something that extends A and implements B would also work, or vice-versa.) This means A and B's distinguishability can change at any time.

Interpretation B is very implicit. It comes down to finding all places in the spec that prohibit implementing a given interface. In this case I found the condition

For a given interface, there MUST NOT be any member defined on any of its consequential interfaces whose identifier is the same as any other member defined on any of those consequential interfaces or on the original interface itself.

but there are others, e.g. the no-cycles condition.

Which is it? And, is this actually implementable, or implemented by existing binding layers?

@bzbarsky
Copy link
Collaborator

The point here is that if two types are distinguishable, then given any object you have to be able to tell which of the two types it is.

This means that if there is an object which can claim to be of both types, they need to not be distinguishable. Therefore interpretation A is the correct one and we should adjust phrasing as needed to make that clear.

To determine if A and B are distinguishable, you have to look at all interfaces in the web platform

Yes, you do. That's necessary to achieve the "given any object" goal. I agree that this is rather annoying, but I don't see how the goal can be achieved otherwise.

And, is this actually implementable, or implemented by existing binding layers?

What Gecko's binding layer implements is the following:

Each interface has a set of interfaces associated with it. This set contains the interface itself, all interfaces inheriting from it (transitively, not directly), and all interfaces that have it as a "consequential interface" or inherit from an interface that has it as a consequential interface. So in your example above, the set associated with Baz just contains Baz itself. The set associated with Foo contains Foo and Baz. The set associated with Bar contains Bar and Baz. Two interfaces are distinguishable if their associated sets are disjoint (have no common members). I believe this is a correct implementation of your interpretation A.

@tobie tobie added ⌛⌛ duration:medium Shouldn't be too long to fix editorial Changes that do not affect how the standard is understood. ☕☕☕ difficulty:hard Excruciating labels Jun 19, 2016
@jyasskin
Copy link
Member

jyasskin commented Oct 4, 2016

Would it make sense to replace "It is not possible for a single platform object to implement both interfaces" with "No platform object implements both interfaces"? The non-local nature of the check is annoying, but at least this makes it clear.

@bzbarsky
Copy link
Collaborator

bzbarsky commented Oct 5, 2016

I think once we have proper mixins this might be a lot easier to spec, especially if we don't allow mixins to be used as types. Because at that point, the only way for two interfaces to not be distinguishable will be if one of them inherits from the other, I believe.

@tobie tobie closed this as completed in 89fc3a3 Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☕☕☕ difficulty:hard Excruciating ⌛⌛ duration:medium Shouldn't be too long to fix editorial Changes that do not affect how the standard is understood.
Development

No branches or pull requests

4 participants