Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə61/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   57   58   59   60   61   62   63   64   ...   294
DelphiLanguageGuide

Naming Conflicts
When one block encloses another, the former is called the outer block and the latter the inner block. If an identifier
declared in an outer block is redeclared in an inner block, the inner declaration takes precedence over the outer one
and determines the meaning of the identifier for the duration of the inner block. For example, if you declare a variable
called 
MaxValue
 in the interface section of a unit, and then declare another variable with the same name in a function
declaration within that unit, any unqualified occurrences of 
MaxValue
 in the function block are governed by the
second, local declaration. Similarly, a function declared within another function creates a new, inner scope in which
identifiers used by the outer function can be redeclared locally.
The use of multiple units further complicates the definition of scope. Each unit listed in a uses clause imposes a new
scope that encloses the remaining units used and the program or unit containing the uses clause. The first unit in a
uses clause represents the outermost scope and each succeeding unit represents a new scope inside the previous
one. If two or more units declare the same identifier in their interface sections, an unqualified reference to the identifier
selects the declaration in the innermost scope, that is, in the unit where the reference itself occurs, or, if that unit
doesn't declare the identifier, in the last unit in the 
uses
 clause that does declare the identifier.
46


The 
System
 and 
SysInit
 units are used automatically by every program or unit. The declarations in 
System
, along
with the predefined types, routines, and constants that the compiler understands automatically, always have the
outermost scope.
You can override these rules of scope and bypass an inner declaration by using a qualified identifier (see Qualified
Identifiers) or a with statement (see With Statements, above).
47


Expressions
This topic describes syntax rules of forming Delphi expressions.
The following items are covered in this topic:
Valid Delphi Expressions
Operators
Function calls
Set constructors
Indexes
Typecasts
Expressions
An expression is a construction that returns a value. The following table shows examples of Delphi expressions:
X
variable
@X
address of the variable X
15
integer constant
InterestRate
variable
Calc(X, Y)
function call
X * Y
product of X and Y
Z / (1 - Z)
quotient of Z and (1 - Z)
X = 1.5
Boolean
C in Range1
Boolean
not Done
negation of a Boolean
['a', 'b', 'c']
set
Char(48)
value typecast
The simplest expressions are variables and constants (described in Data types, variables, and constants). More
complex expressions are built from simpler ones using operators, function calls, set constructors, indexes, and
typecasts.
Operators
Operators behave like predefined functions that are part of the the Delphi language. For example, the expression
(X + Y)
 is built from the variables 
X
 and 
Y
, called operands, with the + operator; when 
X
 and 
Y
 represent integers
or reals, 
(X + Y)
 returns their sum. Operators include @not^*/divmodandshlshras+-orxor=,

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   57   58   59   60   61   62   63   64   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin