[heycam/webidl] Allow dictionary values to default to undefined (#983)

I am writing spec text like this:

> ```webidl
> dictionary D {
>   any data;
> };
> ```
>
> Let |data| be |dict|["data"] if it exists, or undefined otherwise.

It would be nicer if I could write this:

> ```webidl
> dictionary D {
>   any data = undefined;
> };
> ```
>
> Let |data| be |dict|["data"].

The spec currently does talk about undefined constant values. But I think that's separate from the values that are allowed as dictionary defaults, which are specified in https://heycam.github.io/webidl/#idl-dictionaries in the section starting

> If the identifier is followed by a U+003D EQUALS SIGN ("=") and a value (matching DefaultValue), then that gives the dictionary member its default value.

It looks like dictionary defaults are specified in terms of optional argument defaults, which are specified in terms of constants. So the most natural way to make this work is to thread through discussion of undefined constants there, plus grammar updates. We'd have to either say that constant types can be "primitive types or undefined", or we'd have to add undefined to the list of primitive types. Hmm...

-- 
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/issues/983

Received on Thursday, 20 May 2021 19:44:19 UTC