Search your topic here

static and dynamic scope

STATIC AND DYNAMIC SCOPE


The scope of a variable is the region of the program in which variable is declared and used.

One of the basic reasons of scoping is to keep variables in different parts of program distinct from one another. 

Scope is generally divided into two categories:
1.Static Scope
2.Dynamic Scope

1. Static scope: Static scope is also called lexical scope. Static scope refers to scope of a variable is defined at compile time itself that is when the code is compiled a variable to bounded to some block.

2. Dynamic scope: Dynamic scope refers to scope of a variable is defined at run time rather than at compile time. Perl language allows dynamic scoping.

LEAVE A REPLY