Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
SCOPE AND VISIBILITY
Scope
The scope of an identifier is a part of the program in which the identifier can be used
to access its object. There are different categories of scope, which depends on how
and where identifiers are declared:
Visibility
The visibility of an identifier is that region of the program source code from which
legal access to the identifier’s associated object can be made.
Scope and visibility usually coincide, though there are circumstances under which
an object becomes temporarily hidden by the appearance of a duplicate identifier,
i.e. the object still exists but the original identifier cannot be used to access it until
the scope of the duplicate identifier is ended.
Technically, visibility cannot exceed scope, but scope can exceed visibility.
132
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroPASCAL PRO for AVR
CHAPTER 5
Place of declaration
Scope
Identifier is declared
in the declaration of a
program, function, or
procedure
Scope extends from the point where it is declared to the
end of the current block, including all blocks enclosed
within that scope. Identifiers in the outermost scope (file
scope) of the main unit are referred to as globals, while
other identifiers are locals.
Identifier is declared
in the interface sec-
tion of a unit
Scope extends 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.
Identifier is declared in
the implementation sec-
tion of a unit, but not
within the block of any
function or procedure
Scope extends 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.