Re: [heycam/webidl] Specify open dictionaries. (#180)

jyasskin commented on this pull request.



> @@ -7529,6 +7564,82 @@ iterable |iterable| and an iterator getter
 </div>
 
 
+<h4 id="es-open-dictionary">Open dictionaries — dictionary&lt;[|K|,] |V|&gt;</h4>
+
+IDL {{dictionary}}&lt;|K|, |V|&gt; values are represented by
+ECMAScript <emu-val>Object</emu-val> values.
+
+<div algorithm="convert object to open dictionary" id="es-to-open-dictionary">
+    An ECMAScript value |O| is [=converted to an IDL value|converted=] to an IDL <code>{{dictionary}}<|K|, |V|></code> value as follows:
+
+    1.  If [=Type=](|O|) is not <emu-val>Object</emu-val>,
+        <a lt="es throw">throw a <emu-val>TypeError</emu-val></a>.
+    1.  Let |result| be a new empty instance of <code>{{dictionary}}<|K|, |V|></code>.
+    1.  Let |entries| be [=EnumerableOwnProperties=](|O|, "key+value").

@annevk I think step 22, substep 3 of Structured Clone is equivalent to [EnumerableOwnProperties](https://tc39.github.io/ecma262/#sec-enumerableownproperties). There is an interesting question about what order we should type-check vs [[Get]]ing the values. I see at least four options:

1. Get all properties before checking their types (what I have now).
2. Get and check all the keys, and then interleave getting values with checking them.
3. Get all keys, then check a key, get its value, check its value, repeat.
4. Get all keys, then get a key's value, check the key, check the value, repeat.

For sane objects these are the same, but for getters with side-effects they're not.

-- 
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/180#pullrequestreview-2280744

Received on Friday, 30 September 2016 07:39:01 UTC