- From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
- Date: Fri, 31 Jan 2025 23:23:25 +0000
- To: public-css-archive@w3.org
The issue with `lazy()` or similar solutions is that it's not clear *when* it should be resolved. Given an ancestor chain A>B>C, one could set a `--foo: lazy(var(--dep) + 1):` on A, then `--bar: var(--foo) / 2;` on B, and then `width: calc(1px * var(--bar))` on C. On which element is the `lazy()` resolved - B or C? If `--dep` is 1 on A, 10 on B, and 100 on C, what is the final value of `width`? We *could* define that it's whenever you substitute into a "real" (non-custom) property. But that seems (imo) to unfairly demonize custom properties. They could be used as part of a library, where (to the page author) they're just as meaningfully "baseline" as CSS-defined properties. We could define that it's whenever you substitute into a property with a registered (non-universal) grammar, so custom properties can opt themselves into resolving late() by given themselves a grammar. But not all property grammars are expressible in `<syntax>`, so that doesn't seem *ideal*. But that might be the best way to go about it, hrm. Finally, I think it's probably reasonable to sometimes want *some* of the vars in an expression to be resolved immediately, while others are resolved later. ------- On the other hand, we could just say "if you want to define a computation that's resolved at some later time, use custom functions". The evaluation time for custom functions is explicit; it's when they're called. It means there's a bit of a syntax split, but that's something of what we're doing anyway with `lazy()`. It's definitely a bit more fiddly to have to define a (global!) function to defer a calculation, but "inline" functions are on the possible roadmap anyway. And they solve the "some evaluated now, some evaluated later", as we've discussed in a custom function issue - reusing the now-dropped `using` syntax to distinguish between definition-time references and execution-time references. I was trying to sketch one out, but my brain is too fried from WG meetings to provide a realistic example right now. Something to work thru, tho. -- GitHub Notification of comment by tabatkins Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11543#issuecomment-2628558606 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 31 January 2025 23:23:26 UTC