- From: Tab Atkins Jr. via GitHub <noreply@w3.org>
- Date: Wed, 23 Jul 2025 20:01:38 +0000
- To: public-css-archive@w3.org
> We can and do infer types in context. Yes, that's why I specifically said "in general" in the text you quoted. We do not always have appropriate context to be capable of resolving a value to a particular type. (At least, not without expensive/complicated backtracking that can, in the worst case, go exponential in cost, which is strictly unacceptable.) > And two dimensions! Would that add too much complexity? Not to the implementation, no. What it adds complexity to is *the mental model*. If `light-dark()` is *only* a color, and anything else is done with the generic `if()`, that's easy to understand. If `light-dark()` is a color *or* an image, that's not too bad to remember; it's only two things, and they're conceptually related anyway. If `light-dark()` is *three* things, especially if the third thing isn't really conceptually related, it gets harder. Four things makes it worse, etc. The more things it can do, the more complicated the boundary between "can use `light-dark()`" and "have to use `if()`" is. It becomes harder for authors to confidently write code; they either have to guess and check, or just give up and always use the generic `if()` because it always works (even with its drawbacks due to being an arb-sub function). Dimensions have a further issue, which is that where dimensions are used, often there are keywords allowed as well. If `width: light-dark(500px, auto);` doesn't work, how do you explain that to users? If it does work, it means we have to keep more in mind in the future when adding to these categories; we have to make sure that either (a) we never add syntaxes that would make this type-detection ambiguous, or (b) we define that certain values are always detected as a certain type, and you can't use them as the other type. This gets worse as we add more types. So, this is why I'll push back on making `light-dark()` too complicated. ^_^ "Color or image" is fine; going further probably isn't. We have a generic function proposed for this; it's a little more verbose but not terrible. -- GitHub Notification of comment by tabatkins Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12513#issuecomment-3109966313 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 23 July 2025 20:01:39 UTC