8 ms·
My position is that the preprocessor (at least as far as textual substitution macros are concerned) was a mistake even considering the technical limitations of
by qsort 6y ago
My position is that the preprocessor (at least as far as textual substitution macros are concerned) was a mistake even considering the technical limitations of the time, unlike features like raw pointers, abundance of undefined behavior, void, etc., that are bad right now but were completely understandable (and likely even better than any other realistic alternative) at the time.
constexpr + inline would have covered 99% of the macro use cases. Alternatively, a limited system of AST rewriting wouldn't have been significantly harder to write than cpp and would have achieved many of the same goals.
As a totally random, non-factual, non-argumentative guess that could be 100% wrong, I believe the idea of the preprocessor was influenced by the general 'unix philosophy' principle that everything should be treated as text.
- throwaway_pdp09 6y agoNo offence but you're not recognising that things were very, very different. C was designed as a language for small sytems. It's used for ridiculously large and inapprpriate thinga now. The #include is terrible but it was ok back then - things were small enough to hold in your head. No longer. Compilers were simpler back when C was designed. IIRC PDPs often had just a few K of memory. A megabyte would be huge in the 80's. A textual preprocessor can be done in a couple of K I'd guess, or less. Also a preprocessor is useful for many other things unrelated to the C language. I understand your frustration but things started that way for a good reason, please don't criticise unless you really understand that. Feel free to criticise the inertia that means we have much the same stuff nearly half a century later (but also understand why).