Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it true that dictionaries can't have a default value specified? #585

Closed
bzbarsky opened this issue Sep 27, 2018 · 4 comments · Fixed by #750
Closed

Is it true that dictionaries can't have a default value specified? #585

bzbarsky opened this issue Sep 27, 2018 · 4 comments · Fixed by #750

Comments

@bzbarsky
Copy link
Collaborator

bzbarsky commented Sep 27, 2018

There's informative text in https://heycam.github.io/webidl/#idl-operations that says:

Dictionary types cannot have a default value specified explicitly

however it seems to me that null would be a valid default value for a dictionary (meaning empty dictionary, once you go through the es-to-dictionary steps).

@tobie @domenic @marcoscaceres @annevk

@annevk
Copy link
Member

annevk commented Sep 28, 2018

I think we decided not to have a default value (e.g., {}) since it always has a default value.

@bzbarsky
Copy link
Collaborator Author

What always has a default value?

In the current state of the IDL spec, optional dictionary arguments in trailing position always have a default value. I think that non-trailing-position ones should too. But dictionary-typed members of dictionaries do not have a default value, and there are specs relying on that at this point. Firefox used to give them a default value and we just stopped doing that because of those specs. See #76. However some other specs do want to default those to empty dictionary, I suspect. Hence this issue.

@bzbarsky
Copy link
Collaborator Author

For example, DOMQuadInit at https://drafts.fxtf.org/geometry/#dictdef-domquadinit sure seems to assume that its DOMPointInit members get default values. It has no provisions for those members being missing.

@zcorpan

@zcorpan
Copy link
Member

zcorpan commented Jun 28, 2019

Good catch. Yeah, I think I assumed that they would act like {}.

The other option is to default with prose in the algorithm, though that seems less nice.

bzbarsky added a commit to bzbarsky/webidl that referenced this issue Jun 28, 2019
"{}") and require it to be specified for the dictionary arguments that
are required to be optional.

Fixes whatwg#585
Fixes whatwg#602
bzbarsky added a commit to bzbarsky/webidl that referenced this issue Jul 1, 2019
"{}") and require it to be specified for the dictionary arguments that
are required to be optional.

Fixes whatwg#585
Fixes whatwg#602
bzbarsky added a commit that referenced this issue Jul 1, 2019
… "{}") and require it to be specified for the dictionary arguments that are required to be optional. (#750)

Fixes #585
Fixes #602
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants
@zcorpan @bzbarsky @annevk and others