6 ms·
The color:hover example seems like a pretty wild edge case. I'd be interested to see a more solid example of a 'boundless' lookahead requirement. In my simplist
by somishere 4y ago
The color:hover example seems like a pretty wild edge case. I'd be interested to see a more solid example of a 'boundless' lookahead requirement. In my simplistic view surely a strict mode that requires semicolons after properties (as opposed to commas or curly brackets after selectors) would do the trick?
Edit: I put together (painfully typed out on a phone) an example regex[1] to use the color:hover example. It isn't perfect, but it also isnt boundless.
[1] https://regex101.com/r/aOc2Pz/1 https://regex101.com/r/aOc2Pz/1
- Hackbraten 4y agoWouldn’t that break compatibility with existing websites?
- somishere 4y agoNot if you only require strict mode for modern language incantations like nesting
- Hackbraten 4y agoThen you’d have two diverging CSS dialects, which would add complexity, too.
- wruza 4y agoThe problem is not to tell selector from definition (of course it can, otherwise grammar would be non-reducible). The problem is how far in an array of tokens the distinction can be seen. Parsers know the current state and where to go next out of previous reductions and a few lookaheads which they can use at places known to be clear of ambiguity in a ~fixed number of lookaheads. Parsing something that diverges only down few pages of tokens is problematic size/speed/algo-wise, but the question is how much does that cost really and who should pay. Edit: But honestly I think this is all wrong direction. Any technology, format, method has 1. features and 2. form. Form is irrelevant because you can make tools to convert any form into any. Features are important because you can’t add features by tooling. But $subj adds zero features, only a new form which is already feels like a compromise. Why do that then? We have to brush our tools instead, e.g. create default nginx-scss plugin, standalone scss caching servers etc. Then everyone could use extended syntax without resorting to all-in-one monstrosities like webpack.
- scotty79 4y agoNext { or ; is not few pages down. This all seems like purely academic objection that in practice could be made equally fast.
- wruza 4y agoYep, that’s why I find it questionable too. Next { or ; is not few pages down A little nuance is that when it is, we either want to make that illegal or to process this case anyway. Both ways open a next can of worms.
- scotty79 4y agoI guess, if you want to write slowest CSS file on the planet by cramming together three pages of selectors before you open a bracket ... be my guest.
- danielvaughn 4y agoYeah this is my intuition as well, though I haven't spent much time thinking about the problem. Like, yeah, if you write very non-performant code, it won't perform well. So what? Don't write stupid code.
- jakelazaroff 4y agoThe issue is that the person who ends up suffering isn't the developer that writes the CSS. It's the person who has to use the website. If I'm trying to find a local emergency room, I really don't want to have to waste time because a developer wrote (or some tool generated!) slow CSS.
- treeman79 4y agoI had hired in at a new company and was getting annoyed with how slow everything was so I started digging into the Javascript and CSS. I started seeing a lot of references to Chuck Norris. After further digging, found that the entire test library suite was being added to code. Site load time was halved after fixing.
- jagger27 4y agoHacking around “wild edge cases” is how we get impossible to implement standards.