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

Thank you for your response. 

Btw. despite what I read in this thread.. I'd like to add:

"var()" is a "built-in function". "calc()" is a "built-in function". People are used to call functions without a `--` prefix.
Therefore, defining a `--` prefix as a requirement to custom functions is an inconsistency too. `--` is traditionally used to define a var or to dereference it by name. 

Example: `--some-var: #ffffff;` used as a declaration. 
Example 2: `var(--some-var)` used to dereference.

Together with the lists topic this leads to multiple conclusions.
- Simply do not allow to use lists in argument lists of functions. Use vars there.
- Simply don't declare functions with `--`.
- Simply don't come up with a new "return" keyword that does not has the keyword signature of "@", because also this would be an inconsistency.

To give a complete, "consistent" example of what I mean (and an alternative):

```
// CSS standard lists, since the last millennium
--default-custom-fonts: "Some Font with Spaces", sans-serif;

/* a function with default values assigned */
@function custom-font-fn(
  --font-family: var(--default-custom-fonts) /* lists not allowed here, as list in list is... nobody does that?! */
) {
  /* consistent keyword definition for return statements; if less syntax is wanted, why not introduce arrow functions too? */
  @return {
      font-family: var(--font-family);
      /* max define much more... even some nested mixins etc. */
  }
}

.foo {
  @mixin custom-font-fn(); /* uses the default here*/
  color: #ffffff;
}
```

Of course, this is derailing a few ideas, but I think this is more in-line with what CSS used to look like and also more in-line with what the community built and is used to with CSS pre-processor grammar in the field. In the end, people seem to love to type less and also like to have a clear, concise syntax. Extensive use of `--` makes any grammar increasingly hard to read, especially if it is used for different purposes.

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


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

Received on Thursday, 12 December 2024 22:53:28 UTC