IPB

> Rules of scope
Чат
Форум
Загрузка...
 

Language:
Русский
English

  Rules of scope


The presence of an identifier or label in a declaration defines the identifier or label, and each time the identifier or label occurs again, it must be within the scope of this declaration.

The scope of an identifier or label encompasses its declaration to the end of the current block, including all blocks enclosed by the current block. In addition, the scope extends over all descendants of the object type, including field designators and with statements that operate on variable references to the given object type.

Exceptions

1. Redeclaration in an enclosed block: Suppose that Exterior is a block that encloses another block, Interior.

If Exterior and Interior both have an identifier with the same name (for example, J), Interior can only access the J it declared, and Exterior can only access the J it declared.

2. Position of declaration within its block: Identifiers and labels cannot be used until after they are declared.

An identifier or label's declaration must come before any occurrence of that identifier or label in the program text, unless it is the base type of a pointer type that has not yet been declared. However, the identifier must eventually be declared in the same type declaration part that the pointer type occurs in.

3. Redeclaration within a block: An identifier or label can only be declared once in the outer level of a given block, unless it is declared within a contained block or is in a record's field list.

A record field identifier is declared within a record type, and is significant only in combination with a reference to a variable of that record type.

You can redeclare a field identifier (with the same spelling) within the same block, but not at the same level within the same record type.

However, an identifier that has been declared can be redeclared as a field identifier in the same block.

4. An object component's identifier: The scope of an object component's identifier extends over the object type and all descendants and blocks of all method declarations of the object type.

 
 К началу страницы 
Тэги: Scope,Rules_of
 

Код для вставки: :: :: :: ГОСТ ::
Поделиться: //
 



-
Хостинг предоставлен компанией "Веб Сервис Центр" при поддержке компании "ДокЛаб"