This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
This has come up a few times now; people keep wanting dictionaries some of whose entries are required to be present. This is particularly important when writing algorithms that need to operate on separate different dictionaries and hence want to describe all the behavior of the dictionary in IDL, but is helpful for simplifying spec prose in other cases too.
Do you have concrete examples where this is a problem? The few times I've had something like this, IDL syntax would not have helped.
The web crypto spec wants to have a generic algorithm that processes a bunch of different dictionaries. It wants to enforce some values being present, but has no way to do that right now. So they're using nullable to indicate "doesn't have to be present", which is really not what we want. See mail thread at http://lists.w3.org/Archives/Public/public-webcrypto/2014Jul/0029.html and following
Nullable would indeed be wrong as per that thread. Defaulting to an empty ArrayBuffer is not making it required though. Will we throw TypeError or some such for these cases? I guess that seems fine. There are some ideas for JavaScript in general to make certain arguments required, not sure how far along that is now. Hard to track JavaScript proposals.
> Defaulting to an empty ArrayBuffer is not making it required though. Right, they have some optional things that they want to default to empty ArrayBuffers. They have other things that they want to be required, with no defaulting. > Will we throw TypeError or some such for these cases? That would be the idea, yes.
Last few times this came up, we suggested using required arguments, no?
We did, but that doesn't work for APIs like webcrypto which want to take different dictionaries depending on the type of algorithm and some of those dictionaries want to have some required entries. You can't even really do that with overloading, since the behavior depends on the value of a string argument (the algorithm name). People clearly shouldn't _abuse_ this functionality to create functions which just have a single dictionary argument instead of several useful ones, but there are use cases where doing this makes sense. Fwiw, https://github.com/heycam/webidl/pull/17
https://github.com/heycam/webidl/commit/c48499697008a47a068edd912a54ac38489e3ddd