Re: [csswg-drafts] [css-nesting-1] Syntax Invites Errors (#7834)

The CSS Working Group just discussed `[css-nesting-1] Syntax Invites Errors`.

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> Topic: [css-nesting-1] Syntax Invites Errors<br>
&lt;fantasai> github: https://github.com/w3c/csswg-drafts/issues/7834<br>
&lt;emeyer> scribenick emeyer<br>
&lt;emeyer> astearns: fantasai has suggested we should focus on this call on whether we replace the text in the specification with option 3, and then have further discussion later on proposal 4.<br>
&lt;TabAtkins> +1<br>
&lt;lea> +1<br>
&lt;bramus> SGTM<br>
&lt;astearns> https://github.com/w3c/csswg-drafts/blob/main/css-nesting-1/proposals.md<br>
&lt;emeyer> astearns: We have four options with pros and cons, and some poll results<br>
&lt;emeyer> …Most positions are between options 3 and 1, with a smattering of 2 and 4.<br>
&lt;astearns> ack fantasai<br>
&lt;lea> I have added some vote counts under the table<br>
&lt;emeyer> fantasai: many considerations here. We have problems with the current syntax, which requires a lot of ampersands that are hard to remember where they’re needed<br>
&lt;emeyer> …we also want portability of the code structures is a concern with the current syntax<br>
&lt;emeyer> …there was another concern about confusion over spaces, but that seems minor<br>
&lt;emeyer> …Our options are: always prefix, nest into blocks, use a switch to change modes<br>
&lt;emeyer> …We explored many possible syntaxes. Lea?<br>
&lt;emeyer> lea: Option 3, you can nest without ampersands for most selectors<br>
&lt;TabAtkins> q+<br>
&lt;jensimmons> q+<br>
&lt;emeyer> …except the only descendants you need ampersands is element selectors<br>
&lt;argyle> q+<br>
&lt;emeyer> …The advantage is there’s no parser switch, and it’s also much less verbose than current syntax<br>
&lt;emeyer> …If you have a descendant selector that start with an element, you do need to ampersand that<br>
&lt;emeyer> …Compatibility with Sass is not a concern here, because it’s a one-time cost<br>
&lt;emeyer> …In general, the closer we can get to the Sass syntax, the better; developers like it<br>
&lt;emeyer> …People find the current syntax quite noisy<br>
&lt;emeyer> …We might also be able to relax syntax in the future, if we can figure out a way to do so<br>
&lt;emeyer> astearns: Ampersands not required, but allowed, yes?<br>
&lt;fremy> q+<br>
&lt;emeyer> (collective affirmation)<br>
&lt;emeyer> fantasai: Devs seem split 50/50 on use of ampersands or not<br>
&lt;emeyer> …As far as the proposal, the basic rule for nesting a selector is that you can’t start with a letter<br>
&lt;astearns> ack TabAtkins<br>
&lt;dbaron> (I think it's a letter or a dash?)<br>
&lt;lea> dbaron: yes<br>
&lt;emeyer> TabAtkins: While I initially supported option 1, having looked through the details, option 3 is very good<br>
&lt;emeyer> …It most of the time gives you the ability to write like in Sass, with one awkward exception that’s easy to tell apart<br>
&lt;bradk> Sorry to be so incredibly late<br>
&lt;emeyer> …Most of the time you can use an ampersand to nest and it works out fine<br>
&lt;emeyer> …The rule for whether you need it or not is very clear, and this does allow us to be close to Sass<br>
&lt;astearns> ack jensimmons<br>
&lt;emeyer> jensimmons: There are a lot of things about option 3 I really like, but the one thing I feel is a non-starter from my perspective is that not all selectors are treated the same<br>
&lt;emeyer> …Authors have to know that nesting is easy most of the time, except in this one case<br>
&lt;lea> Clarification: I didn't say element selectors were rare *at all*. Element selectors where the parent selector is inserted later (e.g. strong &amp;) is rare.<br>
&lt;emeyer> …I understand the mitigations, the problem is teaching authors that this one selector type is weird, and the syntax isn’t consistent across all selector patterns<br>
&lt;astearns> ack argyle<br>
&lt;lea> q+<br>
&lt;emeyer> argyle: When you go to paste and forget the &amp;, that’s a problem, but syntax highlighters are there to help authors<br>
&lt;emeyer> …Option 1 is the most portable because it’s unambiguous<br>
&lt;emeyer> …The community outside the WG has already passed the WG, which may be why a lot of people didn’t seem to case about the verbosity<br>
&lt;emeyer> …Option 1’s simplicity is appealing for tooling and to machines<br>
&lt;emeyer> …Teaching option 1 is easy, because it’s very consistent<br>
&lt;emeyer> …Teaching 3 or 4 gets muddy and complicated<br>
&lt;miriam> q+<br>
&lt;emeyer> …I did like the idea that most of the suggestions of 3 and 4 build on option 1, so I like the idea of going with option 1 and then in Level 2, we could use 3 and 4<br>
&lt;emeyer> …This would let us unblock engines that already do option 1 now<br>
&lt;fantasai> 4 doesn't build on 3 or 1 or anything<br>
&lt;TabAtkins> 3 has exactly one exception, same as 1 (and imo of the same complexity). 4 has no exceptions. It was the 2 variants that had slightly more complex requirements.<br>
&lt;fantasai> and also doesn't have any exceptions<br>
&lt;astearns> ack fremy<br>
&lt;argyle> correct, 4 doesnt build on 1, my bad<br>
&lt;emeyer> fremy: I’m glad that we aren’t considering option 2. I’m mixed between 1 and 3, and agree with the points mentioned before<br>
&lt;emeyer> …I’m kind of okay with 1, would be fine with 3, the consistency of 1 feel better<br>
&lt;emeyer> s/feel/feels/<br>
&lt;emeyer> If I had to choose, I’d probably say 1, but wouldn’t be mad if we choose 3<br>
&lt;emeyer> …I see myself converting nested rules into scoped rules, which we aren’t really addressing<br>
&lt;argyle> memorizing idents shouldnt be a requirement to nest effectively..<br>
&lt;emeyer> …Having a syntax incompatible with :scope is annoying and a downside<br>
&lt;astearns> zakim, close queue<br>
&lt;Zakim> ok, astearns, the speaker queue is closed<br>
&lt;emeyer> …You shoudl be able to copy and paste anything and not have to rewrite anything<br>
&lt;astearns> ack lea<br>
&lt;emeyer> lea: Replying to jensimmons, I didn’t say element selectors are rare, but that element selectors where the ampersand comes later are rare<br>
&lt;astearns> ack miriam<br>
&lt;emeyer> miriam: Both proposals have weird edge cases<br>
&lt;fantasai> lea mentioned that `strong &amp;` is rare, but `&amp; strong` is fairly common and can be done with &amp; as today<br>
&lt;emeyer> …in option 1, you have to learn when to use or not use @nest<br>
&lt;emeyer> …in option 3, you have to learn when to use ampersands with a descendant<br>
&lt;emeyer> …In my mind it’s a little easier to teach, because I can teach that you always have to start with a symbol<br>
&lt;fremy> miriam: we could just replace `@nest` with `&amp;` and say that if there are one at the start and one later one, the one later one wins<br>
&lt;emeyer> …I do see Adam’s point that 1 and 3 are interoperable if we want them to be<br>
&lt;emeyer> …I don’t know if that’s an interesting approach to take, but it is possible<br>
&lt;jensimmons> I wish we had time to talk about option 4. If we ended up like 4 best, there's no need to debate 1 vs 3, etc.<br>
&lt;emeyer> astearns: I think it’s intriguing to do 1 and then allow 3 in the future<br>
&lt;bradk> I agree with the idea that #3 still allows you to do #1<br>
&lt;emeyer> …We need to take this back to the issue and come back to this next week with another scoped-time discussion<br>
&lt;emeyer> …Please do discuss further in the issue.<br>
</details>


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


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

Received on Wednesday, 19 October 2022 17:01:04 UTC