T3X - A Minimum Procedural Language
Version 8.1.5, Online Edition
|
Copyright(C) 1996-2004
Nils M Holm
|
|
Scoping rules define the contexts in which symbols are valid and
the conditions under which they may be redefined. In T3X, there are
five different contexts and very strict and simple redefinition rules
apply.
- The public context contains public classes and the public
entities defined in their contexts. It contains all public
elements exported by a set of modules. The public context is persistent.
It is not even destroyed when the compilation of a program
ends. The public context may contain any number of class contexts.
(*)
- The global context covers a complete file or module. Its
declarations are located in the space between procedures and
class definitions. Each global context may contain any number of class
contexts or procedure contexts.
- A class context contains all symbols which belong to a
specific class. They are delimited by a class header (CLASS ...
or ICLASS ...) and the keyword END. Each class context
may contain any number of procedure contexts.
- A procedure context is equal to the argument list of a
procedure plus the statement forming the body of the procedure. The
argument list is a list of implicit atomic variable declarations. No
other entities may be defined in this context. A single block context
(forming the body of the procedure) may be embedded in each procedure
context.
- A block context begins with the keyword
DO and ends with the keyword END. Each block context
may contain any number of nested block contexts. Notice that this defintion
is recursive, so that blocks may be nested to any level. A block context
is called blockn context, if there are n enclosing
blocks.
(*) Technical remark: To purge the public symbol table, the storage
holding the table (usually a file) must be cleared (eg by deleting the file).
The following redefinition rules apply:
- Each public class and the entities defined in its context may be
redefined once in the module containing the original definition. (*)
- Each symbol used in a forward declaration (DECL statement)
may be redefined by a one single matching procedure definition.
- Except for forward declarations and public entities, no symbol may
be redeclared or shadowed ever.
- Global names may not be reused at class level, procedure level, or at
block level.
- Class level names may not be reused at procedure level or at block
level.
- Procedure level names may not be reused at block level.
- Block level names may not be reused in embedded blocks.
(*) This happens when a module containing public classes is
recompiled. In this case, the definition in the public context
is silently updated.
+-- Public ------------------------------------+
| +-- Global --------------------------------+ |
| | +-- Class -----------------------------+ | |
| | | +-- Procedure ---------------------+ | | |
| | | | +-- Block**0 ------------------+ | | | |
| | | | | +--- ... ------------------+ | | | | |
| | | | | | | | | | | |
| | | | | | +-- Block**N ----------+ | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | +----------------------+ | | | | | |
| | | | | +--------------------------+ | | | | |
| | | | +------------------------------+ | | | |
| | | +----------------------------------+ | | |
| | +--------------------------------------+ | |
| +------------------------------------------+ |
+----------------------------------------------+
|
| Fig.4 Scopes (overview) |