[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.296 var

Synopsis

As part of a variable declaration part or in a statement block:
 
var variable identifier: type identifier;
or
 
var variable identifier: type definition;
and with initializing value:
 
var variable identifier: type identifier value constant expression;
or
 
var variable identifier: type definition value constant expression;

As part of a parameter list (passing by reference):
 
var var parameter: type identifier;
or without type declaration
 
var var parameter;

or protected (i.e., the called routine can't modify the parameter):
 
protected var var parameter: type identifier;
or without type declaration
 
protected var var parameter;

Description

In a declaration part: The reserved word `var' declares a variable identifier whose type is of type identifier or which is defined by type definition. For further description see section 8.1.5 Variable Declaration, section 8.1.4 Type Declaration, section 8.2.1 Type Definition, section 8.2 Data Types.

In a parameter list: see section 8.1.6.4 Subroutine Parameter List Declaration.

Conforming to

`var' is defined in ISO-7185 Pascal and supported by all known Pascal variants. Untyped `var' parameters in parameter lists are a UCSD Pascal extension. The ability to do `var' declarations in a statement block is a GNU Pascal extension.

Example

 
program VarDemo;

type FooType = Integer;

var Bar: FooType; ArrayFoo: array [0 .. 9] of Integer; { array var definition } FecordFoo: record { record var definition } Bar: Integer end; CharsetFoo: set of Char; { set var } SubrangeFoo: -123 .. 456; { subrange var } EnumeratedFoo: (Mon, Tue, Wed, Thu, Fri, Sat, Sun); {enumerated var } PointerBar: ^FooType; { pointer var }

procedure ReadFoo (var Foo: FooType); begin ReadLn (Foo) end;

begin var Bar: Integer; { GNU Pascal extension } Bar := 42 end.

See also

section 9.284 type, section 9.14 array, section 9.222 record, section 9.244 set, section 8.2.10.1 Subrange Types, section 9.196 Pointer, section 9.206 protected.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Frank Heckenbach on May, 10 2002 using texi2html