Mikroelektronika MIKROE-350 Data Sheet

Page of 526
SCOPE AND VISIBILITY
Scope
The scope of identifier is a part of the program in which the identifier can be used to
access its object. There are different categories of scope, depending on how and
where identifiers are declared:
Visibility
The visibility of an identifier is a region of the program source code from where a
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:
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.
123
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroBasic PRO for AVR
CHAPTER 5
Place of declaration
Scope
Identifier is declared in the
declaration section of the main
module, out of any function or
procedure
Scope extends from the point where it is
declared to the end of the current file, including
all routines enclosed within that scope. These
identifiers have a file scope and are referred to
as globals.
Identifier is declared in the
function or procedure
Scope extends from the point where it is
declared to the end of the current routine. These
identifiers are referred to as locals.
Identifier is declared in the
interface section of the module
Scope extends the interface section of a module
from the point where it is declared to the end of
the module, and to any other module or program
that uses that module. The only exception are
symbols which have a scope limited to the file in
which they are declared.
Identifier is declared in the
implementation section of the
module, but not within any
function or procedure
Scope extends from the point where it is
declared to the end of the module. The identifier
is available to any function or procedure in the
module.