Re: [heycam/webidl] Define a way to specify a default value for dictionaries (the literal "{}") and require it to be specified for the dictionary arguments that are required to be optional. (#750)

Ms2ger approved this pull request.

This seems fine. (My first thought was to use `= null`, but maybe this is clearer.)

> @@ -2337,6 +2343,31 @@ that has a [=sequence type=] in its [=flattened member types=].
     </pre>
 </div>
 
+<div class="example">
+
+    The following [=IDL fragment=]
+    defines an [=interface=]
+    with an operation that takes a dictionary argument:
+
+    <!-- Should be `highlight="webidl"`, but that gives bikeshed conniptions
+         because it does not know about the syntax we are introducing -->
+    <pre>
+        dictionary LookupOptions {
+          boolean caseSensitive = true;

Consider following the advice we give elsewhere:

> As with operation argument default values, it is strongly suggested not to use true as the default value for boolean-typed dictionary members, as this can be confusing for authors who might otherwise expect the default conversion of undefined to be used (i.e., false). 

> @@ -2242,24 +2242,23 @@ corresponding argument omitted.
     conversion of <emu-val>undefined</emu-val> to be used (i.e., <emu-val>false</emu-val>).

Consider adding the new token to

> Note: These values – in addition to strings and the empty sequence – can also be used to specify the default value of a dictionary member or of an optional argument. Note that strings and the empty sequence [] cannot be used as the value of a constant.

-- 
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/750#pullrequestreview-256231262

Received on Monday, 1 July 2019 10:10:45 UTC