3 ms·
They're complex in the sense that they do not follow the rules of the surrounding system. They can produce mismatching parentheses, breaking the pretty basic no
by rtpg 8y ago
They're complex in the sense that they do not follow the rules of the surrounding system. They can produce mismatching parentheses, breaking the pretty basic notion that expressions can be "inlined" into other expressions.
Not knowing whether `f()` is a syntax error or not removes a huge part of the foundation that people use to read code they do not know 100%
- jstimpfle 8y ago> They're complex in the sense that they do not follow the rules of the surrounding system. And this is exactly why they are useful. You can do things with it that you cannot do in any other way. Practical things, I want to mention. Some examples: conditional compilation based on feature set. Automatic insertion of additional arguments (like __FILE__, __LINE__, or the sizeof of arguments). Conversion of identifiers to C strings. Computations such as getting the offset of a member in a struct. Ad-hoc code and datastructure generation. Many of these could be individually replaced with complex features built into the core of the language, by making arbitrary ad-hoc decisions that would be hard to standardize and would probably kill the language. > Not knowing whether `f()` is a syntax error or not removes a huge part of the foundation that people use to read code they do not know 100% It's your responsibility to match parentheses when required (which is almost always). That's easy for a macro that is usually 1, or at most 5 lines. And if something goes wrong, it's usually not that hard to find the error and fix it. You need to be aware of some gotchas though (wrap expressions in parens, don't do naked if statements or blocks but wrap them in do..while(0)). That means you will get to learn the C syntax more intimately.