- From: edbaafi via GitHub <sysbot+gh@w3.org>
- Date: Mon, 24 Feb 2025 19:17:52 +0000
- To: public-css-archive@w3.org
> To be clear I'm not suggesting anything other than swapping the if/else keywords for something else. Since I've been focused on `if` let's take a look at how the current syntax changes the typical use of `else`: Re-reading the [spec](https://www.w3.org/TR/css-values-5/#if-notation) makes me see how weird this is: ``` if( condition1: value1; condition2: value2; else: value3 ) ``` What other language's use of `else` puts it within the `if`'s `()` and has to describe it this way: > The else keyword represents a condition that is always true. This is why `default` seems very appropriate for where this feature ended up (all of the reasons it's structured this way makes sense but now we're left with names that don't match the final structure). I'm going to add a third and fourth point to what we're changing from the typical (especially JS) use of `if`/`else`. 1) working on only values (expressions) rather than whole declarations (statements) - rust aside ;) 2) grouping multiple conditions vs. a single condition and requiring nesting if you want more (or for languages where nesting was undesirable (e.g. python), an additional keyword like `elif`). 3) putting the conditions and resulting values within the `()` e.g. `if( condition: value)` vs `if( condition1) value1` 4) making the `else` a "special" condition of the `if` (within the `if`'s `()`s e.g. `if(condition: value1; else: value2)` rather than a statement/expression at the same structural level as the `if` (e.g. `if(condition: value1) else value2`) All this can be avoided by picking a different name for `if`. I think `default` as a replacement for `else` here makes total sense. That way we can say: "The `default` keyword represents a condition that is always true" in the spec and something like: "We can use `default: <value>` to provide a value to use when any of the previous conditions were not met" in the docs, instead of: "The `else` keyword represents a condition that is always true." in the spec and who knows what in the docs. -- GitHub Notification of comment by edbaafi Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10064#issuecomment-2679426216 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 24 February 2025 19:17:52 UTC