/    /  Compiler Design-Dynamic Scope

Dynamic Scope

 

Dynamic scoping determines the declaration of a name time with the help of current active variables. Snobol uses dynamic scoping. 

 

Example:

#define p(d+1)
void a()
{
 printf("%d", p);
}
void b()
{
 int d=0;
 printf("%d", p);
}
void main()
{
x();
y();
}

In the above example, the value of the variable p is determined at runtime during the execution of the functions. a() and b(). When the function a is called, the value of d remains the same as declared globally.

 

 

Reference Links

Dynamic Scope