Re: [csswg-drafts] [css-values] Make top-level NaN be IACVT instead of ∞ (#7067)

> Yes, but it may be going overboard. If we only tried to maximize incorrect results, we could also say that setting width to a calc() producing -1px also becomes the maximum value instead of being clamped to 0px.

Good thing we're *not* only trying to maximize incorrect results, then. ^_^

Due to our "no open ranges" policy, we *can* assume that any explicitly authored values outside of a valid range are an authoring mistake, and go for the maximally incorrect result of "drop the property as invalid". As long as all ranges are closed, authors can't accidentally write a value close to the boundary that might be across the boundary in some implementations.

This isn't the case for calculations, which due to precision issues *are* possible to kick slightly outside of a valid range by accident. Catastrophizing these cases would be author-hostile when we can tell what the likely intent was, so we just clamp instead. And there's no particularly good reason to set some "maximum error" beyond which we give up and do something maximally incorrect, so we just clamp *all* values.

NaNs don't fall into this bucket - we have no means to predict what they're supposed to be (which is why they're NaN rather than an infinity or something). So nothing we do has even a slight assurance of matching author intent. So the only thing we can do is be maximally incorrect in some arbitrary way. Making the property invalid is out. I chose censoring to Infinity; reducing the whole value to initial or inherit is also possible.

CSS has existing precedent (already given) in cases like this to make the value deliberately, obviously bad. I don't think initial or inherit serves that purpose quite as well as an infinity.  Custom properties need to use that behavior because they can be *anything* and be used *anywhere*; we have *absolutely no idea* what they are meant to substitute as, so we can't do *anything* smarter and obviously wrong. But for numbers we do have a more obviously wrong behavior available.

Like I said, I'm not against changing this in theory, but I do think the current behavior is fine and the suggested change would be slightly worse.  I'm open to an argument that a different behavior would be better for authors, particularly in the recognizability/teachability aspect.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7067#issuecomment-1043683605 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 18 February 2022 00:48:44 UTC