You are on page 1of 6

PROGRAMMING LANGUAGE

BASICS

 Static and Dynamic distinction
 Enviroments and States
 Static scope and Block Structure
 Explicit Access Control
 Dynamic Scope
 Parameter Passing
 Aliasing

Perl language allows dynamic scoping. DYNAMIC SCOPE: Dynamic scope refers to scope of a variable is defined at run time rather than at compile time. . Examples: C.STATIC AND DYNAMIC DISTINCTION STATIC 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 scope if it is local. can be bounded to entire Main block if it is global. Java uses static scoping.C++.

ENVIROMENTS AND SETS  Static vs Dynamic binding of names to locations Globals can be static .others dynamic(strings in java are imutable) .  Static vs Dynamic binding of locations to values Constants can be static.others dynamic.

} . int b = 1. { int b = 2. cout << a << b. } cout << a << b. cout << a << b. } BLOCK } { int b = 4. { int a = 3. } cout << a << b.Static scope and block structure main() { int a = 1.

Explicit access control  Classes introduce new scoping for data members. and protected limit access to data members dynamic scope Use of name x refers to the declaration of x in the most recently called. class Foo { public void x(){ } } class Bar extends Foo { public void x(){ } } . not-yet-terminated. private.  Subclasses act like sub-blocks  public. procedure with such a declaration.

.Dynamic Scope vs Static Scope  Static is most closely related declaration in space  Dynamic is most closely related declaration in time Parameter passing  Call by Value A copy of actual parameter is made and placed in formal parameter  Call by Reference The address of actual parameter is passed as value of the formal parameter Aliasing  When two names refer to the same location in memory  Effects optimization step of compilers.