[heycam/webidl] Does the "required" dictionary member keyword affect output? (#382)

I'm trying to figure out the scope of `required` and `=` default values and whether they apply only to input "values" or to (internally created values and thus) output "values" as well.

At first glance both would seem to only affect input, not output, as they're only referenced in the [ECMAScript value to IDL dictionary](https://heycam.github.io/webidl/#es-dictionary) algorithm, but not in the [IDL dictionary to ECMAScript Object](https://heycam.github.io/webidl/#es-dictionary) algorithm (scroll down in link).

But I learned [a while ago](https://github.com/w3c/mediacapture-main/issues/293#issuecomment-169040860) that at least default values impact output, at least in our webidl compiler, and that the spec at least [implies it](https://github.com/w3c/mediacapture-main/issues/293#issuecomment-169603863) through: *"Dictionary members with default values are always considered to be present."*

Similarly, it says about the `required` keyword: *"If the type of the dictionary member is preceded by the required keyword, the member is considered a required dictionary member and must be present on the dictionary."*

Both hinge on the definition of "present". Present only on input, or internal invariant? I've filed https://github.com/heycam/webidl/issues/381 for clarification.

AFAICT our WebIDL compiler does not do anything to enforce presence of "required" internal values when output, but I wanted some spec clarification. This came up in https://github.com/w3c/webrtc-pc/issues/1476 where people are considering using `required` on output-only dictionaries as a form of normative implementation implication. That may be a good or bad idea on its own, and I have opinions on such an overload, but it comes down to how WebIDL views `required`, what the intent was, and what we might expect WebIDL compilers to enforce in the future.

-- 
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/382

Received on Saturday, 15 July 2017 14:07:37 UTC