Walter Bright wrote:
Jeremie Pelletier wrote:
This may be a good time to ask about how these variables which can be
declared anywhere in the function scope are implemented.
void bar(bool foo) {
if(foo) {
int a = 1;
...
}
else {
int a = 2;
...
}
}
is the stack frame using two ints, or is the compiler seeing only one?
I never bothered to check it out and just declared 'int a = void;' at
the beginning of the routine to keep the stack frames as small as
possible.
They are completely independent variables. One may get assigned to a
register, and not the other.
Ok, that's what I thought, so the good old C way of declaring variables
at the top is not a bad thing yet :)