-
Notifications
You must be signed in to change notification settings - Fork 165
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
Does it make sense for an interface mixin to declare [Default] object toJSON()? #979
Comments
IMO the intention is that folding them would result in the same thing.
I think in general putting two operations with the same name/argument list in an interface, whether via mixins or not, is disallowed? |
OK, so it sounds like this example could be made clearer by avoiding mixins, since they're just adding indirection. Duplicate (not overloaded) operations are indeed not allowed, but I was wondering if like constructors this shouldn't be allowed in partials and mixins at all. But since I ran into this when trying to untangle some things in idlharness.js, but my question is now answered. |
This example was adapted from a previous one in whatwg#433, but things are much simpler now and the example makes it seem more complicated than it really is. Interface mixins aren't special, so make the same point without them. Fixes whatwg#979.
This example was adapted from a previous one in whatwg#433, but things are much simpler now and the example makes it seem more complicated than it really is. Make the points inheritance and mixins separately. This also fixes the order of attributes on the returned JSON object, which was wrong the original example. The attributes of the base interface should be included first. Reverse the inheritance order in the example to make this clearer, matching `interface B : A` in two other examples. Fixes whatwg#979.
I searched for "toJSON" in https://github.com/w3c/webref/tree/master/ed/idl and found that |
This example was adapted from a previous one in #433, but things are much simpler now and the example makes it seem more complicated than it really is. Make the points inheritance and mixins separately. This also fixes the order of attributes on the returned JSON object, which was wrong the original example. The attributes of the base interface should be included first. Reverse the inheritance order in the example to make this clearer, matching `interface B : A` in two other examples. Fixes #979.
This appears in https://heycam.github.io/webidl/#example-tojson-default-inheritance-and-mixins:
Is the use of mixins here in any way significant, or would folding in the mixins result in exactly the same thing?
Put differently, if
[Default] object toJSON()
isn't scoped to the members of the interface mixin, is there anything special going on here?Since https://heycam.github.io/webidl/#default-tojson-steps only operates on the inheritance stack, it seems like this example isn't something one would want to do, and doesn't clearly illustrate why "m3" wouldn't be included in the default
toJSON()
return value. I think that's becauseB
has no[Default] object toJSON()
, that "m3" is in a mixin isn't really relevant.I suspect that this example could be from back when there was
implements
and "consequential interfaces", when things were more complicated.If two
[Default] object toJSON()
operations on the same interface isn't valid, so putting it on a mixin would limit and affect the original interface in an unfortunate way. Maybe it should simply not be allowed?The text was updated successfully, but these errors were encountered: