Re: [csswg-drafts] [css-mixins] Improve ergonomics of `using` by allowing wildcards (#10954)

The CSS Working Group just discussed ``[css-mixins] Improve ergonomics of `using` by allowing wildcards``, and agreed to the following:

* `RESOLVED: Kill using with fire`

<details><summary>The full IRC log of that discussion</summary>
&lt;kbabbitt> TabAtkins: earlier I had implied that the interior of a fuinction can see custom props on element<br>
&lt;kbabbitt> ... questio is how should that be possible to what degree to make it automatic<br>
&lt;kbabbitt> ...current spec makes it not automatic at all<br>
&lt;kbabbitt> ... if you want to see custom props inside function you have to declare<br>
&lt;kbabbitt> ... then they become local varis inside function body<br>
&lt;kbabbitt> ... lea pointed out that doesn't work well in design systems with 100+ custom props<br>
&lt;kbabbitt> ... functions called by other functions also need to declare<br>
&lt;kbabbitt> ... lea's suggestion at first was to have some wildcarding syntax<br>
&lt;kbabbitt> ... but what I came around to instead was to remove that syntax entirely form fcuntion defintion<br>
&lt;kbabbitt> ... make all custom props visible inside custom function<br>
&lt;kizu> q+<br>
&lt;kbabbitt> ... arguments shadow if they have same name<br>
&lt;emilio> q+<br>
&lt;lea> strong +1 to TabAtkins' proposed behavior<br>
&lt;kbabbitt> ... my preference is to make all custom props behave similarly<br>
&lt;kbabbitt> ...nested variables visible in calling function in the same way<br>
&lt;kbabbitt> ... so you ca override when necessary but otherwise don't have to think about it<br>
&lt;lea> Way more flexible than the current syntax OR the wildcard syntax I proposed<br>
&lt;miriam> this matches my original proposal, and I like it :)<br>
&lt;kbabbitt> lea: the using feature is a wart in general, glad to be rid of it<br>
&lt;kbabbitt> ... makes  a lot more use cases possible<br>
&lt;astearns> ack kizu<br>
&lt;astearns> q+<br>
&lt;kbabbitt> kizu: no objection, huge +1<br>
&lt;kbabbitt> ... only thing I want to mention is we could still keep using syntax if we want to allow renaming<br>
&lt;kbabbitt> ... variables from outer scope<br>
&lt;lea> q?<br>
&lt;kbabbitt> ... if we want to use same names in inner scope or as argument names<br>
&lt;kbabbitt> .... could using foo to define outer foo as something else<br>
&lt;lea> q+ to say this sounds like a L2 feature, and something we need more data on<br>
&lt;kbabbitt> ... other than that, having all custom props from outside available at all times would be much more useful<br>
&lt;kbabbitt> TabAtkins: already possible today if you declare a local var and set its value to var to pull from<br>
&lt;kbabbitt> ... probably don't need additional syntax for that<br>
&lt;kbabbitt> ... theoretically there for the future<br>
&lt;astearns> ack emilio<br>
&lt;kbabbitt> emilio: was wondering use case for this originally?<br>
&lt;kbabbitt> TabAtkins: I wanted to be careful about encapsulation<br>
&lt;kbabbitt> ... so you don't accidentally grab unintended variables<br>
&lt;kbabbitt> emilio: seems fine to allow it<br>
&lt;kbabbitt> ... from impl perspective, easy to compute set of variables if needed<br>
&lt;ChrisL> q+<br>
&lt;kbabbitt> ... manual list seems fine<br>
&lt;kbabbitt> TabAtkins: other aspect was, assuming we'll do a JS backed custom fn as well<br>
&lt;kbabbitt> ... at some point<br>
&lt;kbabbitt> ... using syntax made it clear exactly what would be passed to JS context<br>
&lt;kbabbitt> .. instead we'll gether all custom props, probably not a big deal<br>
&lt;lea> q+ to reply to emilio: do we even need to compute them? We can just propagate these `var()`s to the result and have the function return an expression that contains them<br>
&lt;kbabbitt> ...certainly easier to avoid massive repetition in JS than CSS<br>
&lt;kbabbitt> astearns: if it was a good optimization, you could take a look at what props were used and subset things when passing it over js boundary<br>
&lt;kbabbitt> TabAtkins: aliasing is a hard problem<br>
&lt;kbabbitt> astearns: to clarify: what happens when a custom prop is not defined?<br>
&lt;kbabbitt> ... and function is using it?<br>
&lt;kbabbitt> TabAtkins: it's just a var reference<br>
&lt;kbabbitt> ... you use the var syntax, same as anything else<br>
&lt;astearns> ack astearns<br>
&lt;astearns> ack lea<br>
&lt;Zakim> lea, you wanted to say this sounds like a L2 feature, and something we need more data on and to reply to emilio: do we even need to compute them? We can just propagate these<br>
&lt;Zakim> ... `var()`s to the result and have the function return an expression that contains them<br>
&lt;kbabbitt> lea: re: kizu - yes I can see potentially things to adjust how scoping works<br>
&lt;kbabbitt> ... possibly opposite of using and excluding vars<br>
&lt;kbabbitt> ... sound like level 2 features<br>
&lt;weinig> q+<br>
&lt;kbabbitt> ... don't want to expand scope right now, keep it lean so we can ship soon<br>
&lt;kbabbitt> ... re: emilio - do we actually need to compute the union of props being used?<br>
&lt;kbabbitt> ... just propagate var references instead?<br>
&lt;kbabbitt> ... if using vars from outside, instead of fn returning single value, could return an expression that includes var references<br>
&lt;kbabbitt> ... then they get resolved when used<br>
&lt;kbabbitt> emilio: didn't mean to imply they needed to be computed<br>
&lt;kbabbitt> ... looking at names fns are using, can see the names while parsing<br>
&lt;kbabbitt> ... join them when substituting<br>
&lt;kbabbitt> ...if we need for some super fancy optimization we could get that list<br>
&lt;kbabbitt> lea: awesome<br>
&lt;astearns> acl ChrisL<br>
&lt;astearns> ack ChrisL<br>
&lt;kbabbitt> ChrisL: I understand desire from CS standpoint to want to do data hiding<br>
&lt;kbabbitt> ... but in this case passing things it doesn't actually care bout but 8 level deep does care<br>
&lt;kbabbitt> ... passing them through produces less footguns<br>
&lt;astearns> ack weinig<br>
&lt;kbabbitt> weinig: to clarify.... using the programming language jargon, is what's provided here dynamic scoping?<br>
&lt;kbabbitt> TabAtkins: yes<br>
&lt;kbabbitt> weinig: where you call the function, element or scope there defines additional ?<br>
&lt;kbabbitt> TabAtkins: variable definition doesn't have meaningful scope<br>
&lt;kbabbitt> ...carrying on existing dynamic scoping of inheritance that custom prtops rely on<br>
&lt;kbabbitt> Proposed: Kill using with fire<br>
&lt;TabAtkins> s/meaningful scope/meaningful lexical scope/<br>
&lt;kbabbitt> RESOLVED: Kill using with fire<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10954#issuecomment-2623138036 using your GitHub account


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

Received on Wednesday, 29 January 2025 23:15:24 UTC