Re: [heycam/webidl] Sort out when dictionaries and records should have default values (#76)

Yes, the two cases are indeed related, but semantically different (IMO). As @bzbarsky [points out][comment],

>Dictionaries as initially designed are meant to be equivalent to a bunch of trailing optional arguments, but easier to use because you can specify only the arguments you want instead of all the ones before the last one you want (with undefined for the ones you don't want). [...]

In this sense, I can agree that `undefined`, `null` and `{}` should all be equivalent - but I do not agree that the same rule should apply for the members inside that root dictionary, as I explain in https://github.com/w3c/webauthn/issues/750#issuecomment-401752095.

So under my proposition, with the definitions

```
function foo(Arguments args) {
}

dictionary Arguments {
  Thing aThing;
}

dictionary Thing {
  required DOMString id;
}
```

these invocations would all be equivalent and valid:

- `foo()`
- `foo(undefined)`
- `foo(null)`
- `foo({})`
- `foo({ aThing: undefined })`

but this would be invalid due to the missing `id` member:

- `foo({ aThing: {} })`

...whereas if `aThing` also implicitly defaults to `{}`, then all of the above invocations would be equivalent, and therefore invalid since the last one is invalid.

[comment]: https://github.com/heycam/webidl/issues/76#issuecomment-394057351

-- 
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-401920306

Received on Monday, 2 July 2018 20:14:56 UTC