C
Chad
The following question stems from Static vs Dynamic scoping article in
wikipedia.
http://en.wikipedia.org/wiki/Scope_(programming)#Static_versus_dynamic_scoping
Using this sites example, if I go like this:
#include <stdio.h>
int x = 0;
int f () { return x; }
int g () { int x = 1; return f(); }
int main(void) {
printf("%d\n",g());
return 0;
}
I get
$gcc -Wall bi.c -o bi
bi.c: In function `g':
bi.c:5: warning: unused variable `x'
$./bi
0
I'm assuming this means (in this case) that x is static scoped, right?
Chad
wikipedia.
http://en.wikipedia.org/wiki/Scope_(programming)#Static_versus_dynamic_scoping
Using this sites example, if I go like this:
#include <stdio.h>
int x = 0;
int f () { return x; }
int g () { int x = 1; return f(); }
int main(void) {
printf("%d\n",g());
return 0;
}
I get
$gcc -Wall bi.c -o bi
bi.c: In function `g':
bi.c:5: warning: unused variable `x'
$./bi
0
I'm assuming this means (in this case) that x is static scoped, right?
Chad