Re: [whatwg/webidl] WIP: switching maplike/setlike to use infra maps and sets (PR #1138)

@domenic commented on this pull request.

This round of editorial fixes seems likely final-ish...

> @@ -12995,207 +12872,301 @@ with the following characteristics:
         The [=map size getter=] is a [=built-in function object=]
         whose behavior when invoked is as follows:
 
-        1.  Let |O| be the <emu-val>this</emu-val> value.
-        1.  If |O| [=is a platform object=],
-            then [=perform a security check=], passing:
-            *   the platform object |O|,
-            *   the identifier "<code>size</code>", and
-            *   the type "<code>getter</code>".
-        1.  If |O| does not [=implement=] <var ignore>A</var>, then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
-        1.  Let |map| be the {{ECMAScript/Map}} object that is the value of |O|’s \[[BackingMap]] [=internal slot=].
-        1.  Return [=!=] <a abstract-op>Get</a>(|map|, "<code>size</code>").
+        1.  Let |O| be the <emu-val>this</emu-val> value, [=implementation-checked=] against <var ignore>a</var> with identifier "<code>size</code>" and type "<code>getter</code>".

```suggestion
        1.  Let |O| be the <emu-val>this</emu-val> value, [=implementation-checked=] against <var ignore>A</var> with identifier "<code>size</code>" and type "<code>getter</code>".
```

here and below

> @@ -12995,207 +12872,301 @@ with the following characteristics:
         The [=map size getter=] is a [=built-in function object=]
         whose behavior when invoked is as follows:
 
-        1.  Let |O| be the <emu-val>this</emu-val> value.
-        1.  If |O| [=is a platform object=],
-            then [=perform a security check=], passing:
-            *   the platform object |O|,
-            *   the identifier "<code>size</code>", and
-            *   the type "<code>getter</code>".
-        1.  If |O| does not [=implement=] <var ignore>A</var>, then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
-        1.  Let |map| be the {{ECMAScript/Map}} object that is the value of |O|’s \[[BackingMap]] [=internal slot=].
-        1.  Return [=!=] <a abstract-op>Get</a>(|map|, "<code>size</code>").
+        1.  Let |O| be the <emu-val>this</emu-val> value, [=implementation-checked=] against <var ignore>a</var> with identifier "<code>size</code>" and type "<code>getter</code>".
+        1.  Let |map| be the [=map entries=] of the IDL value
+            that represents a reference to |O|.
+        1.  Return |map|'s [=map/size=], [=converted to an ECMAScript value=].
     </div>

There appears to be a stray `<div>` here. If we put a `<div algorithm>` around the entire section then we could remove the `<var ignore>`.... or we could just delete this.

>  
+<div algorithm>
+    To <dfn>create a map iterator</dfn>
+    from a [=/map=] |map|
+    and a |kind| which is either "<code>key+value</code>", "<code>key</code>", or "<code>value</code>"):

```suggestion
    and a |kind| which is either "<code>key+value</code>", "<code>key</code>", or "<code>value</code>":
```

>  
+<div algorithm>
+    To <dfn>create a map iterator</dfn>
+    from a [=/map=] |map|
+    and a |kind| which is either "<code>key+value</code>", "<code>key</code>", or "<code>value</code>"):
+
+    1. Let |closure| be a new [=/Abstract Closure=] with no parameters
+        that captures |map| and |kind| and performs the following steps when called:
+        1. [=map/For each=] |key| → |value| of |map|:
+            1. Set |key| and |value| to each [=converted to an ECMAScript value=].
+            1. If |kind| is "<code>key</code>", let |result| be |key|.
+            1. Else if |kind| is "<code>value</code>", let |result| be |value|.
+            1. Else, let |result| be [$CreateArrayFromList$](« |key|, |value| »).
+            1. Perform [=?=] [$GeneratorYield$]([$CreateIterResultObject$](|result|, <emu-value>false</emu-value>)).

```suggestion
            1. Perform [=?=] [$GeneratorYield$]([$CreateIterResultObject$](|result|, <emu-val>false</emu-val>)).
```

I found three other instances, so a general Ctrl+F for "emu-value" would be worthwhile.

> +    and a |kind| which is either "<code>key+value</code>", "<code>key</code>", or "<code>value</code>"):
+
+    1. Let |closure| be a new [=/Abstract Closure=] with no parameters
+        that captures |map| and |kind| and performs the following steps when called:
+        1. [=map/For each=] |key| → |value| of |map|:
+            1. Set |key| and |value| to each [=converted to an ECMAScript value=].
+            1. If |kind| is "<code>key</code>", let |result| be |key|.
+            1. Else if |kind| is "<code>value</code>", let |result| be |value|.
+            1. Else, let |result| be [$CreateArrayFromList$](« |key|, |value| »).
+            1. Perform [=?=] [$GeneratorYield$]([$CreateIterResultObject$](|result|, <emu-value>false</emu-value>)).
+
+            Note: The [=map/size=] of |map|, and the order of its entries,
+            might have changed while execution of this abstract operation
+            was paused by [$Yield$].
+        1. Return <emu-value>undefined</emu>.
+    1. Return [$CreateIteratorFromClosure$](|closure|, "%MapIteratorPrototype%", {{%MapIteratorPrototype%}}).

```suggestion
    1. Return [$CreateIteratorFromClosure$](|closure|, "<code>%MapIteratorPrototype%</code>", {{%MapIteratorPrototype%}}).
```

here and for the set counterpart

>  
-The value of the [=function objects=]’ <code class="idl">length</code> properties is the Number value <emu-val>0</emu-val>.
+The value of the [=function object=]'s <code class="idl">length</code> properties is the Number value <emu-val>0</emu-val>.

properties -> property, here and below

>  
-The value of the [=function object=]’s <code class="idl">name</code> property is the String value "<code>keys</code>" or "<code>values</code>", correspondingly.
+The value of the [=function object=]’s <code class="idl">name</code> property is the String value "<code>entries</code>".

It isn't really your mess to clean up but now we have inconsistent smart vs. not-smart quotes on these clauses... if you wanted to make them consistent (probably not-smart?) then that would make things slightly nicer.

>          1.  Return |O|.
     </div>
 
 The value of the [=function object=]’s <code class="idl">length</code> property is the Number value <emu-val>2</emu-val>.
 
 The value of the [=function object=]’s <code class="idl">name</code> property is the String value "<code>set</code>".
 
+Note: If the interface does declare a <code class=idl>set</code> method,

```suggestion
If the interface does declare a <code class=idl>set</code> method,
```

(don't use normative language "should"/"must" in non-normative notes)

Here and below

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/pull/1138#pullrequestreview-962360511

You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/pull/1138/review/962360511@github.com>

Received on Wednesday, 4 May 2022 19:19:39 UTC