Chapter 6:Runtime System

Scope of declaration

. A declaration is a syntactic construct associating information with a name

- Explicit declaration :Pascal (Algol class of languages) var i : integer

- Implicit declaration: Fortran i is assumed to be integer

. There may be independent declarations of same name in a program.

. Scope rules determine which declaration applies to a name

. Name binding

 

A declaration in a language is a syntactic construct associating information with a name. There can be two types of declarations

. Explicit declaration : Pascal (Algol class of languages) e.g.- var i : integer.

. Implicit declaration: e.g.,- In Fortran the variable i is assumed to be integer unless declared.

There may be independent declarations of the same name in different parts of a program. The portion of the program to which a declaration applies is called the scope of the declaration. An occurrence of a name in a procedure is said to be local to the procedure if it is in the scope of a declaration within the procedure, or else it is called nonlocal. Scope rules determine which declaration applies to a name.