Re: [heycam/webidl] Replace serializers by toJSON and [Default] extended attribute (#323)

domenic commented on this pull request.



> +
+    The following [=IDL fragment=] defines a number of [=interfaces=]
+    which are [=inherited interface|inherited=] or [=consequential interfaces=] of `A`,
+    as show in the below inheritance tree.
+
+    <pre>
+                  F*
+                  |
+             C    E - I*
+             |    |
+             B* - D*
+             |
+        G* - A - H*
+    </pre>
+
+    Interfaces markes with an asterixk ("*")

"asterisk"

> +          attribute DOMString y;
+        };
+
+        interface I {
+          [Default] object toJSON();
+          attribute DOMString z;
+        };
+
+        A implements G;
+        A implements H;
+        B implements D;
+        E implements I;
+    </pre>
+
+    Calling the <code>toJSON</code> method of an object
+    implementing interface `A` defined above

`<code>` instead of backticks

> +        E implements I;
+    </pre>
+
+    Calling the <code>toJSON</code> method of an object
+    implementing interface `A` defined above
+    would return the following JSON object:
+
+    <pre highlight=json>
+    {
+        "w": "...",
+        "z": "...",
+        "u": "...",
+        "s": "...",
+        "x": "...",
+        "y": "..."
+    }

OK, so it would be easier to check this if the lowercase property names matched the uppercase interface names.

So, this order is a bit surprising to me. I would the following interface order:

> C, B, F, E, I, D, A, G, H

My reasoning is:

- First go to the most distance ancestor on the JavaScript prototype chain (C).
- Then go to the next-most-distance, B
- Then go B's mixins
  - But D has inheritance, so go up its "chain", ending up with F; then E plus its I mixin; then finally D
- Now we can do A, and then its two mixins, G and H.

---

This all might be moot once we simplify interfaces... but I think it'd be good to get right, if possible. We could add a warning that we anticipate such complex inherited/consequential interface chains not being possible in the future, which would make all this less ridiculous. Probably linking to the mixin issue I'm about to open.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/pull/323#pullrequestreview-38260586

Received on Monday, 15 May 2017 23:41:05 UTC