Scope

An identifier, such as a variable or function name, can be used only within the scope of its declaration. The location of a declaration determines its scope. An identifier declared within the declaration of a program, function, or procedure has a scope limited to the block in which it is declared. An identifier declared in the interface section of a unit has a scope that includes any other units or programs that use the unit where the declaration occurs. Identifiers with narrower scope, especially identifiers declared in functions and procedures, are sometimes called local, while identifiers with wider scope are called global.

The rules that determine identifier scope are summarized below.

If the identifier is declared in ...

its scope extends ...

the declaration section of a program, function, or

from the point where it is declared to the end of the current

procedure

block, including all blocks enclosed within that scope.

the interface section of a unit

from the point where it is declared to the end of the unit,

and to any other unit or program that uses that unit. (See

Programs and Units.)

from the point where it is declared to the end of the unit. The identifier is available to any function or procedure in the unit, including the initialization and finalization sections, if present.

the implementation section of a unit, but not within the block of any function or procedure from the point where it is declared to the end of the unit. The identifier is available to any function or procedure in the unit, including the initialization and finalization sections, if present.

the definition of a record type (that is, the identifier is the from the point of its declaration to the end of the record-name of a field in the record) type definition. (See Records.)

the definition of a class (that is, the identifier is the name from the point of its declaration to the end of the class-of a data field property or method in the class) type definition, and also includes descendants of the class and the blocks of all methods in the class and its descendants. (See Classes and Objects.)

the implementation section of a unit, but not within the block of any function or procedure

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment