Re: [csswg-drafts] [css-values-5] What is the MVP for inline conditionals on custom properties? (#10064)

@tabatkins Thanks for your response, and sure, I think that addresses the first point, so we can disregard that.  Again, I think this is a big win in terms of functionality.  I think the fact that CSS will get many more "features that are programming-ish" is exactly why this needs a bit more thought.

I think the rust example is a good one because that's a language that has both statements and expressions where a fully functional language like Elm does not.  For languages with both (I've been using the analogy that declarations are like statements and everything after the `:` in a declaration is like an expression), it is important that `if` can be used for both statements and expressions.  

I know this is the `MVP for inline conditionals` as the post title says, and that so far it's been decided not to provide conditionals for declaration blocks, but if this position changes in the future would you be able to make that use of `if` make sense or would you be forced to pick a different keyword? 

How would the syntax with the current issues I addressed as points 2-4 look with declaration blocks not just values?  (I'm not asking us to focus on if this feature is likely but just as a thought experiment to understand the syntax that has been decided on).

```
<selector> {
    if( style(--type: success) : {
            color: var(--green-60);   
            border-color: var(--green-90);   
        };
        style(--type: warning) : {
            color: var(--yellow-60);   
            border-color: var(--yellow-90);   
        };
        else : {
            color: var(--red-60);   
            border-color: var(--red-90);   
        }
}
```

So yes, functional languages without statements (and those like rust that seem to try to split the difference) have named their conditional expressions `if` and sure they work on expressions, but which ones do the things I addressed as points 2-4 (single `if` keyword for multiple conditions, putting the condition and result in parens `()`, and nesting the if within the `()` at a different hierarchical level than the `if`)? 

I think it's great that CSS will get many more "features that are programming-ish" and just think that we should nod to the norms there wherever we can.  The point that CSS is _**different**_ is also well taken, so if a given keyword evokes certain expectations across many languages (again just focusing on points 2-4), shouldn't we find a _**different**_ keyword?
 



-- 
GitHub Notification of comment by edbaafi
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10064#issuecomment-2679730640 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 21:49:23 UTC