C89 includes blocks you know...
Posted Jun 10, 2008 21:36 UTC (Tue) by ballombe
Parent article: Implications of pure and constant functions
The Dead Code Elimination optimization can be very helpful to reduce the
overhead caused by code written to conform to C89 standard, where you
couldn't mix variables (and constant) declarations with executable code.
In those sources, you had to declare variables at the top of the function, and then start to check for prerequisites. If you wanted to make it explicit that some variable had to keep its value, by making it constant, you would often have to fill them before the prerequisites could be checked.
Actually C89 only requires to declare variables at the top of a block, and you could nest blocks arbitrarily, so the limitation
you mention did not exist, you just had to create a new block:
int is0 = (n==0);
const double z=1/((double) n);
C99 allows to omit the extra braces, but that's about it.
to post comments)