-
Notifications
You must be signed in to change notification settings - Fork 143
CalcDictionary members probably shouldn't be nullable and have default values #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We need to know which units had a defined value (even if 0) when doing things like addition or interpolation. Just confirming - you only meant the above for CalcDictionary, not for CalcLength, right? |
Checking for the dictionary member being present or not lets you do that.
I did, but you could do it for |
Shane said "when doing things like addition or interpolation". That's after construction. You are correct that we don't need nullable for CalcDictionary, because we can just check for whether it's specified or not. That is still makes some patterns slightly awkward, but it's not killer. The same argument applies to optional function args, but ES purposely chose to allow specified But CalcLength needs nullable, no matter what. We operate under two competing constraints for serialization:
#1 requires that we either allow null to indicate "not specified", or set all unspecified things to 0 and then omit 0s. #2 requires that we not omit 0s that were specified. So we have to allow nulls. |
But making its nullable could be confusing. What's the meaning of null vs. unspecified in CalcLength, then? It is clear that we cannot make all of the items In addition, making functions output a long object with lots of null fields for unspecified items doesn't sound sensible. Imagine that, you provide
(Even longer in the future.) Could we probably tolerate null/undefined values for input (that says, treat them as unspecified, or remove fields with those values before further handling), but make them non-nullable? |
You're mixing concepts. That's a recipe for confusion! In the current spec for CalcDictionary, there's no difference between a key being unspecified, and it being specified with In CalcLength, there's no such thing as "unspecified". It's got a bunch of attributes, which are always present. Some of them are nullable. These get set to null by the CalcDictionary-based constructor as described above, or by the .parse() method, where every unit that's not explicitly present in the |
I'm not making any function output that. I think you read my previous response wrong. |
Note that explicit undefined will be treated the same as a missing dictionary member. So you could still have:
and write |
For some reason I thought |
Ah, I wasn't aware that explicit undefined had the same "pretend it wasn't specified" behavior in dictionaries as it did in argument lists. Cool. In that case, great, let's make CalcDictionary members non-nullable. CalcLength members still need to be nullable. (It's annoying that our legacy behavior is for attributes to use "null" as the unspecified value, rather than "undefined". I assume this is one of those Java legacies.) |
* fixed: wrong camelCase: KeyFrameEffect -> KeyframeEffect * fixed typo: WorklerAnimation -> WorkletAnimation * added missing CSS object, and * updated index.html
…on (#801) * Fixed typos and mistakes in code examples. (#107) * fixed: wrong camelCase: KeyFrameEffect -> KeyframeEffect * fixed typo: WorklerAnimation -> WorkletAnimation * added missing CSS object, and * updated index.html * Add [Exposed] to interfaces (#109) Add appropriate [Exposed] to interfaces. https://heycam.github.io/webidl/#idl-interfaces says: "Non-callback interfaces which are not annotated with a [NoInterfaceObject] extended attribute, and callback interfaces which declare constants must be annotated with an [Exposed] extended attribute."
I'm not sure why the
CalcDictionary
members are all defined to be nullable and havenull
default values. As there's no definition of theLengthValue.fromDictionary
method it's hard to tell. :-) But probably you just want:and then in the definition of the
fromDictionary
method (and theCalcLength
constructor) you can check whether a given dictionary member is present or not.The text was updated successfully, but these errors were encountered: