- From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
- Date: Wed, 31 Mar 2021 17:28:46 +0000
- To: public-css-archive@w3.org
> Now we need to specify aaalll the math between none and other values. Not looking forward to that... I mean, it's identical to the math y'all were planning to write (or have already written in Color 4, afaict) between NaN and the other values. ^_^ Afaict, it's just "if you're pairing it with another color, for any reason, take the other color's channel; otherwise, treat it like 0deg", right? (And then, while we're here, we can maybe do the same with chroma for black and white, like d3.js does?) ------- > This discussion made me wonder why none of the JS libraries use undefined or null to represent undefined hues, and use NaN instead. 🤔 I was wondering that too... > Because it plays nice with floats. If you have a NaN and try to multiply it (or anything) it returns NaN. You try and multiply a null, it's treated as zero. So if you add null + 3 you get 3 and lose its null status. Oh gosh, that makes perfect sense, and is sad. :( I mean, it gives wrong results either way; mixing a NaN hue with a 20deg hue wants to produce a 20deg hue for the intermediate result, not a NaN hue, so you have to special-case it in either case. But I suppose it does make it more obvious that you've forgotten that undefined hue can exist when you're doing calculations by hand and suddenly get a surprise NaN. > Eventually we're gonna need to specify a Color object for the Web Platform, outside of Typed OM, and this issue will come up again. What should we use there? I'm happy to leave that decision for Future Tab, Future Lea, and Future Chris to deal with. ^_^ It might be that, at that point, using a NaN makes sense in that object, and I wouldn't object to it if so. Or it might be that, say, we represent it as the string "none" (which also has obvious, tho slightly different, error behavior - `"none" * 3` is `NaN`, while `"none" + 3` is `"none3"`). Whatever the result is, tho, it'll be reasonably optimized for JS usage, which doesn't necessarily correspond with optimizing for CSS usage. -- GitHub Notification of comment by tabatkins Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6107#issuecomment-811273324 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 31 March 2021 17:28:48 UTC