Re: [csswg-drafts] [css-values-5] Add `spread()` to CSS (#8391)

> With that model in mind, would CSS sets always work use a semicolon delimiter rather than another symbol?

If we need to separate `<declaration-value>`s, yes, our only options for delimiters are `;` and `!`. All other values are *potentially* valid parts of the `<declaration-value>`. (See <https://w3c.github.io/csswg-drafts/css-syntax/#any-value>)

> Also, would this be valid syntax,

Invalid under `spread2()` (only allowed in a `*` grammar); valid but does the wrong thing in `spread1()` (it'll be equivalent to `random-item(--x; (1; 2; 3))`, which has only a single item to choose from).

> I think it could be useful for spread() to take in variables

Note that in either option, you *only* use `spread()` in the custom property. In the function you're spreading into you just use `var()` normally. Using `spread()` directly inside of `random-item()` doesn't do anything.

(That is, we're *not* defining a higher-level concept of "a list of values", and then invoking it at the usage point to spread it into multiple args, like the JS `...` operator. *All* we're doing is putting a wrapper around some values, so we can safely use `<any-value>` rather than `<declaration-value>`, and then removing the wrapper once actual substitution happens.

> I do wonder in regard to the delimiter if it would help to be able to spread into other properties using a different delimiter.

None of those examples need any help. All of them can be accomplished today using custom properties and `var()`. The sole problem that needs solving is storing something with a `;` in it (or, theoretically, a `!`) in a custom property, because those two tokens aren't allowed at the top-level of a property.

(This does make me lean towards `spread2()`, fwiw, because making it unambiguously a thing only usable in custom properties probably avoids this sort of confusion with JS's `...` operator.)

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


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

Received on Thursday, 2 February 2023 21:30:44 UTC