3 ms·
A fun and somewhat illuminating exercise in C is to simply try minimizing the number of semicolons in your programs. Pick any comfortable, well-defined task and
by RodgerTheGreat 7y ago
A fun and somewhat illuminating exercise in C is to simply try minimizing the number of semicolons in your programs. Pick any comfortable, well-defined task and spend a few hours refining an implementation.
Fewer semicolons means fewer statements. Apart from simplifying the structure of ones code overall, this also drives writing in a somewhat more functional style. You will find yourself taking advantage of the comma and ternary operators more, if you don't already. Macros are another tool for decreasing repetition. So is expressing programs in a "data-oriented" style, using lookup tables instead of explicit conditionals. If something is used only once, inlining it can reduce the number of distinct statements.