Re: [heycam/webidl] Make interface prototype object creation imperative (#494)

tobie commented on this pull request.



> -        [=interface prototype object=]
-        for the inherited interface.
-    1.  Otherwise, if |A| is declared with the [{{LegacyArrayClass}}]
-        extended attribute, then return {{%ArrayPrototype%}}.
-    1.  Otherwise, return {{%ObjectPrototype%}}.
+    1.  Let |proto| be null.
+    1.  If |interface| is declared with the [{{Global}}] [=extended attribute=],
+        and |interface| [=support named properties|supports named properties=],
+        then set |proto| to the [=named properties object=] of |interface|,
+        as defined in [[#named-properties-object]].
+    1.  Otherwise, if |interface| is declared to inherit from another interface,
+        then set |proto| to the [=interface prototype object=] in |realm|
+        of that [=inherited interface=].
+    1.  Otherwise, if |interface| is declared with the [{{LegacyArrayClass}}] [=extended attribute=],
+        then set |proto| to |realm|.\[[Intrinsics]].[[{{%ArrayPrototype%}}]].
+    1.  Otherwise, set |proto| to |realm|.\[[Intrinsics]].[[{{%ObjectPrototype%}}]].

Feels like the pattern described in https://infra.spec.whatwg.org/#variables is the issue here. I mean you literally have an if…otherwise if…otherwise set of statements right above it, so there's absolutely no chance for this to happen, and yet it's not super obvious to the eye.

Should we write the below instead?

```
    1.  Let |proto| be |realm|.\[[Intrinsics]].[[{{%ObjectPrototype%}}]]..
    1.  If |interface| is declared with the [{{Global}}] [=extended attribute=],
        and |interface| [=support named properties|supports named properties=],
        then set |proto| to the [=named properties object=] of |interface|,
        as defined in [[#named-properties-object]].
    1.  Otherwise, if |interface| is declared to inherit from another interface,
        then set |proto| to the [=interface prototype object=] in |realm|
        of that [=inherited interface=].
    1.  Otherwise, if |interface| is declared with the [{{LegacyArrayClass}}] [=extended attribute=],
        then set |proto| to |realm|.\[[Intrinsics]].[[{{%ArrayPrototype%}}]].
```



-- 
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/494#discussion_r161189070

Received on Friday, 12 January 2018 10:37:52 UTC