Constant expressions | Previous Top Next

A constant expression is an expression that the compiler can evaluate without executing the program in which it occurs. Constant expressions include numerals; character strings; true constants; values of enumerated types; the special constants True, False, and nil; and expressions built exclusively from these elements with operators, typecasts, and set constructors.
This definition of a constant expression is used in several places in Pascal's syntax specification. Constant expressions are required for initializing global variables, defining subrange types, assigning ordinalities to values in enumerated types, specifying default parameter values, writing case statements, and declaring both true and typed constants.
Examples of constant expressions:
100
'A'
256 - 1
(2.5 + 1) / (2.5 - 1)
'iPi' + ' ' + 'Developer'
Chr(32)
Ord('Z') - Ord('A') + 1