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

> @LeaVerou I took a read through the CSS almanac, thanks for the link (and the research, which is thorough and valuable and interesting!). So apologies in advance for picking out this particular paragraph, but it seems relevant.
> 
> > There are also [recent](https://github.com/w3c/csswg-drafts/issues/5009) [discussions](https://github.com/w3c/csswg-drafts/issues/5624) in the CSS WG about introducing a limited form of conditionals, and Sass gives us some data on how commonly this is needed. Almost two thirds of SCSS sheets contain at least one `@if` block, making up almost two thirds of all control flow statements. There is also an if() function for conditionals within values, which is the second most common function used overall (14%).
> 
> That the use of Sass `@if` is an indication of the need for a generic `@if` (the very one we're discussing now) - when in fact they accomplish wildly different things. CSS `@if` will be entirely related to the current execution context, whereas Sass `@if` is evaluated at compile time? You can't replace Sass `@if` calls in any scenario with CSS `@if` (or vice versa). Sass users will need Sass `@if` just as much after this lands as they did before
> 
> Anyway I think we agree on the underlying issues here, but perhaps just not their weight. The need for constructive engagement now is very clear

@simonbuerger Two things:

1. Please note that these discussions linked have nothing to do with the conditionals we are discussing here. Follow the links and read the threads and you'll see. Remember that research is from 2020. I am hoping however that the conditionals we are now defining as a generalization of css-conditional will eventually be extended to support more arbitrary expressions without us having to add a separate conditional syntax.
2. Assuming that Sass authors are a representative *sample* of CSS authors (and 4% is a pretty good sized sample!), the fact that they use `@if` in 63% of Sass stylesheets does strongly indicate that a need for conditionals exists. The percentage of Sass authors using `@if` implies nothing about the percentage of CSS authors who are also Sass authors.

> The SQL part doesn't convince me.
> 
> `IF` is used in stored _procedures_, which as their name implies are not declarative.
> 
> The declarative part of SQL uses `WHERE` clauses, and `CASE`/`WHEN`.
> 
> The `IIF()` (not `if`) function in SQLite is sugar for the `CASE`/`WHEN` construct.

Nope, [`IF()` is a function](https://www.geeksforgeeks.org/mysql-if-function/) and can be used in regular SELECT queries.

> Regarding the precedent, SASS was created in 2006. when CSS2.1 was in the works, and the progress pace was glacial. Nowadays, the WG is buslting with proposals, and it would be foolish to claim an `@rule`... but at the time CSS felt set in stone so I wouldn't fault SASS for picking CSS-like syntax at that point, and I think the WG could extend a modicum of empathy to the dev community rather than steam-rolling it.

Oh I definitely sympathize with their predicament. In fact, I still have projects using Sass myself, so I’m actually one of the authors that would have to migrate! But I don't think the problem of migration is so insurmountable that the only way forward is to worsen CSS, and it's unfortunate they are not willing to discuss possible migration paths to minimize trouble for their users. Also, as another commenter said, this just kicks the ball down the road — they will eventually need to figure out a strategy and migrate to a syntax that will never clash with CSS, otherwise we will keep having these issues, so they may as well do it earlier rather than later so we can adopt the more sensible name in CSS.

> Rather than stomping on folks and ruling by fear, what would be useful to avoid this in the future would be to carve out a terse namespace for non-standard, server-side extensions where the WG promises not to tread. Vendor prefixes don't cut it for this they are too verbose for the core logic of a language (they turned out not to cut it for their intended client-side purpose either, for different reasons).
> 
> `@-sass-if` ? nah!
> 
> `@@if`? That could be more palatable.

That would only work for atrules. What do you do for functions?


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


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

Received on Thursday, 17 March 2022 14:16:32 UTC