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

Consider requiring optional dictionary defaulting explicitly #602

Closed
annevk opened this issue Dec 18, 2018 · 5 comments · Fixed by #750
Closed

Consider requiring optional dictionary defaulting explicitly #602

annevk opened this issue Dec 18, 2018 · 5 comments · Fixed by #750

Comments

@annevk
Copy link
Member

annevk commented Dec 18, 2018

Instead of

foo(optional dictionaryType arg);

perhaps we should require writing

foo(optional dictionaryType arg = {});

for consistency with other optional arguments and for clarity for the reader. At least anecdotally this seems to be one of the most confusing things about IDL that's not a legacy feature.

@bzbarsky
Copy link
Collaborator

Or optional dictionaryType arg = null, though either one is probably ok... We just need to introduce new syntax to do = {}, last I checked, while = null should just work.

@annevk
Copy link
Member Author

annevk commented Dec 21, 2018

I suspect that = null might have the same problem and could even lead to prose that branches on null.

@bzbarsky
Copy link
Collaborator

OK. As long as people are clear on = {} meaning "empty dictionary", not "dictionary initialized from a {} JS object literal", since those are not the same thing...

@bzbarsky
Copy link
Collaborator

@annevk One question: would we still require the = {} on trailing (or all?) dictionary args to be present for the IDL to be valid? That seems generally desirable to me...

@annevk
Copy link
Member Author

annevk commented Jun 28, 2019

Yeah, I was thinking it would be a syntax error without it. I suspect we should require it always, to make it clear it's what happens when you pass undefined and you cannot branch on "dict not given" or some such.

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
3 participants
@bzbarsky @annevk and others