Re: [csswg-drafts] [css-mixins-1] Allow typed custom properties inside custom functions (#12317)

@JaneOri 
> (Current implementation parameters are being computed by the global registration)

I'm not sure what you mean by this. Can you elaborate?

> If local variables aren't registered globally, it should be the same syntax to register them nested in the body.

Not against this, but it is fairly verbose to register custom props, when all you need is a type here. As @LeaVerou said, we can probably design a shorthand form that just takes type and initial value, identical to the current argument syntax.

> Parameters aren't optional and should not have their own syntax for typing either - it should use at property from inside the function body too.

Oh gosh no, that would be so awkward and weird. *Almost* no programming language acts like that. (You have to go back to Fortran and friends to find one.) Every single one *in reasonable use* declares names, params, and defaults in the arglist, more or less exactly like `@function` does. (Exact syntax varies a bit of course, but they all rhyme.)

> There is no overwhelming reason to type result separately either if the dependency tree plainly reveals the type immediately because the var it returns is registered with at prop inside the body. If it returns more than one var token or isn't a registered var, etc, then consider it untyped result)

I think you're asking for type inference of the return value type, based on where it's used? That's not plausible in CSS as it is; most uses would be uninferrable due to grammar flexibility. The only purpose of the return type, anyway, is to grammar-check the value and turn it into the GIV if it's wrong. It's pretty minimal.

@LeaVerou 
> We _could_ make things more consistent though by having a short-form `@property` syntax that takes the same syntax as a function argument, e.g. `@property --foo <length>;`. I think that would be independently useful as a QoL improvement.

I think we should go further and let it take an initial value, too, perfectly matching the arglist grammar. I'll open a separate issue.

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


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

Received on Thursday, 7 May 2026 23:13:23 UTC