3 ms·
Yes, stuff like the `a * b` ambiguity (declaration or expression?), typedef being just another storage class specifier (thus, `static int var` and `typedef int
by bluetomcat 9y ago
Yes, stuff like the `a * b` ambiguity (declaration or expression?), typedef being just another storage class specifier (thus, `static int var` and `typedef int mytype` being the exact same syntactic forms), having complex rules for implicit promotions and conversions, the mess between signed and unsigned.
All of these design warts of C show up clearly when attempting to write a compiler and are not very obvious to most users of the language.
- pjmlp 9y agoFunction pointer declarations is also a fun one, specially in a function declaration as return value and parameters.
- userbinator 9y agoTypedefs are a little trickier to handle (particularly the "when do they actually take effect" part), but "the `a * b` ambiguity" is not hard, because if 'a' is a typedef or qualifier/specifier or basically anything that a declaration can start with, it's a declaration. C++, on the other hand, is definitely far harder to parse, especially if you include things like templates.