-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Rational
- In the bad old days macros were the only way to do inline functions in C. This is no longer the case; GCC has supported inline functions since forever and C99 standardized them. Modern compilers inline automatically and make much better decisions about it than we do. Macros can actually hurt performance by defeating optimizations.
- Macros are untyped which makes them harder to use, lint, debug, and defeats intellisense in IDEs.
- Macros expand to impenetrable spaghetti code like
(car(cdr(car(cdr(car(cdr(nd))))))))), making it difficult to examine intermediate output for debugging.
Of course macros are still the only way to do metaprogramming in C (short of code-generation) so we'll have to keep any macros like that.
Implementation
Just rewrite macros as functions and add appropriate types.
I would suggest tackling logo.h first since that has the biggest impact.
Next would probably be the graphics API.
Then the terminal API.
After that it's a long tail.
Impact
This change should have no functional impact on the program except perhaps a slight performance boost and easier maintenance going forward.
It will result in a large number of line changes which will obscure earlier git history, so we should time it to happen right after a release and not in the middle of a development cycle. OTOH the vast majority of our code hasn't changed since the initial git commit 17 years ago, so maybe there isn't much history to lose.
Priority
Low. This will pay long term dividends but there's no rush.