Re: [csswg-drafts] [css-values] Type conversion functions (#6408)

#1026 and #542 cover the current use cases of converting counter values to numbers and any kind of value to strings.

Note that the main point of this issue is to discuss whether it would be better to provide a unified and explicit way for type conversion instead of having different mechanisms. And the idea of making _all_ type conversions explicit actually rised from the discussion in #542, as I initially mentioned.

> The problem with a general conversion function is that often these conversions are impossible, so the function needs to either give up and return `NaN` or do weird stuff (like JS' `parseInt()` and `parseFloat()`).
> ...
> Note that the conversion to strings is an entirely different issue that is discussed in #542.

You're right. Though I don't see this as a problem but an advantage of an explicit function. And I include string conversion in this, as that is probably the most common use case for type conversions.

Of course a general mechanism as I mentioned it in my initial post has the downside that it's much longer to write than implicit conversion. Also in relation to @LeaVerou's point, it might not be obvious to authors if and how specific conversions actually work.
Though again, I believe a general explicit way of converting different values into each other is better than doing it implicitly or having different solutions for different cases.

Sebastian

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


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

Received on Monday, 1 November 2021 15:32:51 UTC