Next: , Previous: Conjugate, Up: Reference



const

(Under construction.)

Synopsis

Description

Constant declaration or constant parameter declaration.

Conforming to

const is defined in ISO 7185 Pascal and supported by all known Pascal variants. const parameters are a Borland Pascal extension. Pointers to const are a GNU Pascal extension.

Constant declarations allow you to define names for constant (unchanging) values, such as using SecondsPerHour instead of 3600. This can make your program much more readable and maintainable.

GNU Pascal allows you to define constant strings, records and arrays as well as simple numeric constants.

GNU Pascal also implements the const parameter extension which allows the compiler to pass parameters by reference while still allowing you to pass constant values as inputs. See Subroutine Parameter List Declaration for more information.

@@ Pointers to const @@

Example

     program ConstDemo;
     
     type
       Rec = record
         x: Integer;
         y: Integer;
       end;
     
     const
       a = 5;
       constr: Rec = (10, 12);
     
     procedure doit (const r: Rec; const s: String);
     begin
       WriteLn (r.x);
       WriteLn (r.y);
       WriteLn (s);
     end;
     
     var
       variabler: Rec;
     
     begin
       variabler.x := 16;
       variabler.y := 7;
       doit (variabler, 'Should be 16 and 7');
       doit (constr, 'Should be 10 and 12');
     end.

See also

Keywords, var, protected, Subroutine Parameter List Declaration.