Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   dynamic scoping (http://www.go4expert.com/forums/dynamic-scoping-t18151/)

dano 23Jun2009 00:58

dynamic scoping
Can someone help me understand dynamic scoping with this example?

void fun1(void);      /*prototype*/
void fun2(void);    /*prototype*/
void fun3(void);    /*prototype*/

void main () {
    a, b, c;
void fun1(void) {
    int b, c, d;
void fun2(void) {
  int c, d, e;
void fun3(void) {
  int d, e, f;

Given the following calling sequence and assuming that dynamic scoping is used, what variales are visible during execution of the las function called? include with each visible variale the name of the function in which it was defined.

a. main calls fun1, fun1 calls fun2; fun2 calls fun3
b. main calls fun1; fun1 calls fun3
c. main calls fun2; fun2 calls fun3; fun3 calls fun1
d. main calls fun3; fun3 calls fun1
e. main calls fun1; fun1 calls fun3; fun3 calls fun2
f. main calls fun3; fun3 calls fun2; fun2 calls fun1

Thank you in advance

xpi0t0s 23Jun2009 02:39

Re: dynamic scoping
Seems a trick question to me because there is an obvious answer and you might think why are they asking if it's that obvious, but what do you think the answer is dano, and why?

All times are GMT +5.5. The time now is 13:55.