Re: [csswg-drafts] [css-conditional-4] Rename @when to @if (#6684)

@romainmenke 

> Is it possible that sass @if can still be a superset of css @if?
> As far as I can tell it's possible to detect sass @if in the syntax of the boolean condition.

I'm not a Sass expert, but you may be correct. Less does this with several functions that were added to CSS, or whose argument syntax was changed (which, I guess, didn't have heated discussions to avoid because of breaking Less and Sass, lol) to allow functions to "pass-through" if it doesn't match Less's supported syntax.

The downside is that the compiler can't really "validate" what's passed through (although, in general, a CSS pre-processor probably _should_ allow invalid syntax to pass through, for various spec reasons). In other words, a Less author may have been _intending_ to write a valid Less function, and for those special-case functions, Less will not throw an error and will instead output as-is (if a parsing / evaluation error is present).

AFAIK, Sass took a different approach of name-spacing Sass functions, and asking people to re-write existing code (I think?). But yes, in the case of `@if`, you could probably look at what's being tested, determine that what's being tested is either a Sass variable or these new CSS functions, and determine evaluation vs. pass-through at eval time, like Less does. 🤷‍♂️ 

I think another reasonable proposal mentioned above is just to alias `@when` to `@if`, because it's unlikely that if `@if` was used, that `@when` would ever be defined to mean something else. Then Sass could use `@when` and everyone else could use whatever makes sense in their mental model. I realize I've been generally grumpy about the whole idea, but I'm starting to get why people might want a general-purpose `@if` for future expansion, especially when both `@media` and `@supports` are a kind of "if statement".

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


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

Received on Wednesday, 23 March 2022 20:00:02 UTC