- From: Emil Lundberg <notifications@github.com>
- Date: Mon, 02 Jul 2018 03:58:25 -0700
- To: heycam/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 2 July 2018 10:58:52 UTC
I agree with @jan-ivar that defaulting optional dictionary members to the empty dictionary is a violation of the principle of least astonishment. As noted in https://github.com/w3c/webauthn/issues/750#issuecomment-401752095, as an API author I expect to be able to express parameter structures where "this thing is optional, but if it's present then there's a required thing inside it". Reading through this thread, though, I note that the case of nested dictionaries seems very different from the case of dictionaries as function arguments. I'm willing to agree that as _function arguments_, it's reasonable that optional dictionary arguments default to the empty dictionary - so that "no bag of arguments" is equivalent to "empty bag of arguments" as noted by @bzbarsky. However, dictionaries as optional _dictionary members_ should default to `undefined` (unless an explicit default is given), because having those default to `{}` would unnecessarily make WebIDL much less expressive. [tbm]: https://w3c.github.io/webauthn/#dom-collectedclientdata-tokenbinding [ccd]: https://w3c.github.io/webauthn/#dictdef-collectedclientdata -- 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/76#issuecomment-401766639
Received on Monday, 2 July 2018 10:58:52 UTC