Strongly disagree. I want to have variables that only exist within an `if` block. That is something C99 got right.
But Python's leaky scopes are even worse than up-front declarations.
But Python's leaky scopes are even worse than up-front declarations.
When you start to have a screen height full of variable-declaration, you start thinking: "Maybe I should refactor this." Inline variables conceal that a bit.
C89 allowed you to declare variables at the top of any block, not just functions, so you could declare variables that only exist within in if block. For example:
if (flag) {
int c;
while ((c = getchar()) != EOF) {
/* code */
}
}