Re: [whatwg/encoding] Editorial: require returned dictionary members (#185)

A required dictionary member is defined to be always present.  There are steps in https://heycam.github.io/webidl/#es-to-dictionary that ensure that invariant, but someone creating a dictionary on the IDL side (e.g. in a spec algorithm) must ensure that they provide a value for required members to produce a valid instance of the dictionary.  At least in Gecko, bindings enforce that.

Which means that `required` in a return value dictionary serves as useful documentation: this member will always be present in the return value.  You could get that from carefully reading the algorithm that creates the return value, of course, but I feel that it's nice to just be able to see it from the IDL.

(There may also be optimization opportunities for JITs here if they can know the shape/hidden-class/etc of the objects coming out of the call ahead of time, but I don't know how important that is in this specific case, and the in-practice monomorphic nature of the return value means that at worst the JIT ends up with one extra guard.)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/encoding/pull/185#issuecomment-531206140

Received on Friday, 13 September 2019 11:47:19 UTC