You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This rewrites some of the text around dictionaries to clear up the confusion in #852, as well as generally try to smooth out the reading experience and definitions. Concrete changes:
* Rewrote "dictionaries are always passed by value" to be more specific and clear.
* Moved "dictionaries must not be used as the type of an attribute or constant" near the top of the dictionary section, commensurate with its importance.
* Removed the terms "present" and "not present"; instead we can use Infra's "exists" for maps.
* Fixed several cases where the overload resolution algorithm discussed arguments being "not present", even though that was only defined for dictionaries. Instead it now correctly talks about "missing".
* Rewrote the discussion of required dictionary members and dictionary members with default values to make it clear how they contribute to the dictionary's entries.
* Added a note to the IDL-to-ES conversion algorithm for dictionaries explicitly pointing out that default-value dictionary members will always be present, and thus always show up in the output.
Closes#852. Closes#524.
in a dictionary value if the value [=map/exists|contains an entry with the key=]
4790
-
given by the member's [=identifier=], otherwise it is [=not present=].
4791
-
Dictionary members can also optionally have a <dfn id="dfn-dictionary-member-default-value" for="dictionary member" export>default value</dfn>, which is
4792
-
the value to use for the dictionary member when passing a value to a
4793
-
[=platform object=] that does
4794
-
not have a specified value. Dictionary members with default values are
4795
-
always considered to be present.
4787
+
[=Dictionary members=] can be specified as
4788
+
<dfn id="required-dictionary-member" export for="dictionary member">required</dfn>, meaning that
4789
+
converting a language-specific value to a dictionary requires providing a value for that member. Any
4790
+
dictionary member that is not [=dictionary member/required=] is
<emu-t>required</emu-t> keyword, the member is considered a [=dictionary member/required=]
4901
+
[=dictionary member=].
4889
4902
4890
4903
<pre highlight="webidl" class="syntax">
4891
4904
dictionary identifier {
@@ -5007,10 +5020,6 @@ The identifier of a dictionary member must not be
5007
5020
the same as that of another dictionary member defined on the dictionary or
5008
5021
on that dictionary’s [=inherited dictionaries=].
5009
5022
5010
-
Dictionaries must not be used as the type of an
5011
-
[=attribute=] or
5012
-
[=constant=].
5013
-
5014
5023
No [=extended attributes=] are applicable to dictionaries.
5015
5024
5016
5025
<div data-fill-with="grammar-Partial"></div>
@@ -7890,9 +7899,7 @@ the object (or its prototype chain) correspond to [=dictionary members=].
7890
7899
running the following algorithm (where |D| is the [=dictionary type=]):
7891
7900
7892
7901
1. If <a abstract-op>Type</a>(|esDict|) is not Undefined, Null or Object, then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
7893
-
1. Let |idlDict| be an empty dictionary value of type |D|;
7894
-
every [=dictionary member=]
7895
-
is initially considered to be [=not present=].
7902
+
1. Let |idlDict| be an empty [=ordered map=], representing a dictionary of type |D|.
7896
7903
1. Let |dictionaries| be a list consisting of |D| and all of |D|’s [=inherited dictionaries=],
7897
7904
in order from least to most derived.
7898
7905
1. For each dictionary |dictionary| in |dictionaries|, in order:
@@ -7908,13 +7915,12 @@ the object (or its prototype chain) correspond to [=dictionary members=].
7908
7915
</dl>
7909
7916
1. If |esMemberValue| is not <emu-val>undefined</emu-val>, then:
7910
7917
1. Let |idlMemberValue| be the result of [=converted to an IDL value|converting=] |esMemberValue| to an IDL value whose type is the type |member| is declared to be of.
7911
-
1. Set the dictionary member on |idlDict| with key name |key| to the value |idlMemberValue|. This dictionary member is considered to be [=present=].
7918
+
1. [=map/Set=] |idlDict|[|key|] to |idlMemberValue|.
7912
7919
1. Otherwise, if |esMemberValue| is <emu-val>undefined</emu-val> but |member| has a [=dictionary member/default value=], then:
7913
7920
1. Let |idlMemberValue| be |member|’s default value.
7914
-
1. Set the dictionary member on |idlDict| with key name |key| to the value |idlMemberValue|. This dictionary member is considered to be [=present=].
7915
-
1. Otherwise, if |esMemberValue| is
7916
-
<emu-val>undefined</emu-val> and |member| is a
7917
-
[=required dictionary member=], then throw a {{ECMAScript/TypeError}}.
7921
+
1. [=map/Set=] |idlDict|[|key|] to |idlMemberValue|.
7922
+
1. Otherwise, if |esMemberValue| is <emu-val>undefined</emu-val> and |member| is
7923
+
[=dictionary member/required=], then throw a {{ECMAScript/TypeError}}.
7918
7924
1. Return |idlDict|.
7919
7925
</div>
7920
7926
@@ -7933,10 +7939,13 @@ up on the ECMAScript object are not necessarily the same as the object’s prope
7933
7939
1. For each dictionary |dictionary| in |dictionaries|, in order:
7934
7940
1. For each dictionary member |member| declared on |dictionary|, in lexicographical order:
7935
7941
1. Let |key| be the [=identifier=] of |member|.
7936
-
1. If the dictionary member named |key| is [=present=] in |V|, then:
7937
-
1. Let |idlValue| be the value of |member| on |V|.
7942
+
1. If |V|[|key|] [=map/exists=], then:
7943
+
1. Let |idlValue| be |V|[|key|].
7938
7944
1. Let |value| be the result of [=converted to an ECMAScript value|converting=] |idlValue| to an ECMAScript value.
0 commit comments