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

I think you are making the point that `if` is valid anywhere `when` is, in this context, (as in: it's more generic). You then concluded that `if` should then be used because it's the most natural for programmers around the world to express this type of branching, regardless of the fine details of the semantics. I think that's a valid point. I would clearly not oppose changing to `if` for that reason if there is a large majority who thinks the same.

But it doesn't mean that `when` is not more correct in this context, I would argue that often it is. So, if there was a vote, I would vote for the statu quo I guess.

As I saw other people ask for examples of why `when` is sometimes a better fit, I will propose 
```css
/* when it's sunny, sunglasses are visible but umbrellas are hidden */
@when <it's sunny> {
     .sunglasses { visibility: visible; }
     .umbrella { visibility: hidden; }
}
/* when it's overcast, both umbrellas and sunglasses are hidden */
@when <it's overcast> {
     .umbrella, .sunglasses { visibility: hidden; }
}
/* when it's raining, umbrellas are visible, but sunglasses are hidden */
@when <it's raining> {
     .umbrella { visibility: visible; }
     .sunglasses { visibility: hidden; }
}
```
This is my mental model of media queries (as in how I "read" them in my mind). Now I understand that other models are possible. It's not impossible to read these sentences with `if` instead. I just like it less (as it's less informative about the fact that this condition might change over time). It's why a vote might be the only thing that's worth doing over this. Different mental models will yield different preferences.

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


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

Received on Wednesday, 13 October 2021 10:33:53 UTC