2.1 Ordinary constants

Ordinary constants declarations are not different from the Turbo Pascal or Delphi implementation.

_________________________________________________________________________________________________________ Constant declaration
-- constant declaration--identifier-=---expression--;----------------------
___________________________________________________________________

The compiler must be able to evaluate the expression in a constant declaration at compile time. This means that most of the functions in the Run-Time library cannot be used in a constant declaration. Operators such as +, -, *, /, not, and, or, div, mod, ord, chr, sizeof, pi, int, trunc, round, frac, odd can be used, however. For more information on expressions, see chapter 6, page 197. Only constants of the following types can be declared: Ordinal types, Real types, Char, and String. The following are all valid constant declarations:

 Const
   e = 2.7182818;  { Real type constant. }
   a = 2;          { Ordinal (Integer) type constant. }
   c = '4';        { Character type constant. }
   s = 'This is a constant string'; {String type constant.}
   s = chr(32)
   ls = SizeOf(Longint);
Assigning a value to an ordinary constant is not permitted. Thus, given the previous declaration, the following will result in a compiler error:
   s := 'some other string';