Re: [csswg-drafts] Proposal: Custom CSS Functions & Mixins (#9350)

Just to provide another example where lists are inconsistently-defined in CSS, let's take [Custom Properties](https://www.w3.org/TR/css-variables-1/).

The `var()` function is defined like this:
```
var( <custom-property-name> [,] [<declaration-value>])
```
The spec goes on to explain:
> Note: The syntax of the fallback, like that of [custom properties](https://www.w3.org/TR/css-variables-1/#custom-property), allows commas. For example, `var(--foo, red, blue)` defines a fallback of `red, blue`; that is, anything between the first comma and the end of the function is considered a fallback value.

Internally, it's fine. Once you know how `var()` works, you know how it works. From a _language and grammar_ perspective, it's terribly inconsistent. What you have in the case of `var(--foo, red, blue)` is, as noted in the spec, **two arguments** separated by **three commas**. If other functions worked like this, okay fine, except they don't. Commas in other functions denote the number of arguments. Except when they don't.

Which then brings us back to something like: `--custom-fn({var(--args)})`

So now, it's yet another inconsistency added to other CSS list inconsistencies. That is, there's the notion of coalescing a comma-separated value into a single one... except, if that were a defined concept in CSS, then you would presumably see it in `var()`, `var(--foo, { red, blue })` and you don't. I get that `var()` was created before this use case, but that's partly my point -- these specs keep adding to the "concept" of lists without ever formally defining it in syntax. IMO it's just unwise to further expand this concept without a formal definition.

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


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

Received on Wednesday, 13 November 2024 20:15:47 UTC