If people had an appreciation for just how much havoc the lexer hack causes in C and C++, there wouldn't be anywhere near the amount of complaining about modern languages that put types after identifiers (var x: int) instead of the reverse (int x).
-
-
Replying to @pcwalton
Wait, what havoc does the C lexer hack cause? I've never found it a big deal in a proper compiler, and in tools I've always been able to get away with pseudo-parsing C without tracking typenames. (I'm sure it's different in C++, and I'm also 100% behind 'x:int' regardless.)
1 reply 0 retweets 1 like -
parentheses around the declarator in the declaration of a function parameter
1 reply 0 retweets 0 likes -
(or is it an unnamed parameter whose type is a pointer-to-function type? depends on name lookup!)
1 reply 0 retweets 0 likes -
-
-
(i guess i shouldn't have said "around the declarator", since the redundant parentheses in the first 'int(n)' are part of the declarator)
1 reply 0 retweets 0 likes -
btw i'd tend to call it the "expression parser hack", since Ritchie re-used the expression parser as the declarator parser (and "lexing" usually refers to the phase where preprocessing tokens are determined, which is before '#' directives are executed)
1 reply 1 retweet 1 like -
Replying to @JamesWidman @pcwalton
So, I'm not sure there's any significant quantity of code that is at risk for being misparsed. Like, only case here is tools that don't properly parse, and the only ambiguity is h(), since C doesn't allow unnamed parameters in definitions, only declarations. So where's the havoc?
3 replies 0 retweets 0 likes -
Replying to @nothings @JamesWidman
IMO the biggest problem in C is that declaration order has to be significant because otherwise you can't parse properly. This means that e.g. the AST of a file can depend on what it
#includes.2 replies 0 retweets 4 likes
This means that C has to reparse header files over and over, leading to compilation time problems. Precompiled headers are hard to implement correctly--on macOS they were broken for a long time, so projects often disabled them.
-
-
The classic way to implement precompiled headers in GCC is literally to parse a bunch of headers, then core dump. Then you can start from that core dump when compiling your code. That's what macOS used to do. (Yes, really.)
3 replies 1 retweet 9 likes -
This is an abomination and prevents building GCC as PIE or running GCC on nommu hosts. I encountered that and was so angry. Is it fixed yet?
1 reply 0 retweets 0 likes - 3 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.