Pascal
ISO 7185:1990
This online copy of the unextended Pascal standard is provided only as an aid to standardization.
In the case of di erences between this online version and the printed version, the printed version
takes precedence.
Do not mo dify this do cument. Do not include this do cumentinanothersoftware pro duct. You may
print this do cument for p ersonal use only. Do not sell this do cument.
Use this information only for good; never for evil. Do not exp ose to re. Do not op erate heavy
equipment after reading, may cause drowsiness. Do not read under the in uence of alcohol (although
there havebeen several uncon rmed rep orts that alcohol actually improves the readability). The
standard is written in English. If you have trouble understanding a particular section, read it again
and again and again... Sit up straight. Eat your vegatables. Do not mumble.
c
ISO/IEC 1991
ISO/IEC 7185:1990(E) ii
ISO/IEC 7185:1990(E)
Acknowledgements
The e orts are acknowledged of all those who contributed to the work of the BSI and ISO Pascal
working groups, and in particular:
Tony Addyman Harris Hall John Reagan
Albrecht Biedl Carsten Hammer Mike Rees
Bob Brewer Atholl Hay Arthur Sale
Co en Bron Tony Hetherington Paula Schwartz
David Burnett-Hall Steve Hobbs Barry Smith
David Bustard Mel Jackson John Souter
Barry Byrne Scott Jameson Manfred Stadel
Klaus Daessler David Jones Bob Tennent
Richard De Morgan David Joslin Tom Turba
Norman Diamond KatsuhikoKakehi Eiiti Wada
Bob Dietrich Olivier Lecarme Willem Wakker
Ken Edwards Jim Miner David Watt
Jacques Farre Wes Munsil Jim Welsh
Bill Findlay Bill Price Brian Wichmann
The e orts are acknowledged of all those who contributed to the work of JPC, and in particular:
Michael Alexander Steven Hobbs David L. Presb erg
Je rey Allen Alb ert A. Ho man William C. Price
Ed Barkmeyer Rob ert Hutchins Bruce Ravenal
W. Ashby Boaz Rosa C. Hwang David L. Reese
Jack Boudreaux Scott Jameson David C. Robbins
A. Winsor Brown David Jones Lynne Rosenthal
Jerry R. Bro okshire Steen Jurs Tom Rudkin
Tomas M. Burger Mel Kanner Stephen C. Schwarm
David S. Cargo John Kaufmann RickShaw
Richard J. Cichelli Leslie Klein Carol Sledge
Jo e Cointment Bruce Knob e Barry Smith
Roger Cox Dennis Ko dimer Rudeen S. Smith
Jean Danver Ronald E. Kole Bill Stackhouse
Debra Deutsch Alan A. Korteso ja Marius Tro ost
Bob Dietrich Edward Krall Thomas N. Turba
Victor A. Folwarczny Rob ert Lange Prescott K. Turner
G. G. Gustafson Rainer McCown Howard Turtle
Thomas Giventer Jim Miner Rob ert Tuttle
Hellmut Golde Eugene N. Miya Richard C. Vile, Jr
David N. Gray Mark Molloy Larry B. Web er
Paul Gregory William Neuhauser David Weil
Michael Hagerty Dennis Nicholson Thomas R. Wilcox
Charles E. Haynes Mark Overgaard Thomas Wolfe
Christopher Henrich Ted C. Park Harvey Wohlwend iii
ISO/IEC 7185:1990(E)
Steven Hieb ert Donald D. Peckham Kenneth M. Zemrowski
Ruth Higgins David Peercy
Charles Hill Rob ert C. B. Poon
(The ab ove list is of p eople acknowledged in ANSI/IEEE770X3.97-1983.) iv
ISO/IEC 7185:1990(E)
Intro duction
This International Standard provides an unambiguous and machine indep endent de nition of the
programming language Pascal. Its purp ose is to facilitate p ortabilityofPascal programs for use on
a wide variety of data pro cessing systems.
Language history
The computer programming language Pascal was designed by Professor Niklaus Wirth to satisfy two
principal aims
a) to make available a language suitable for teaching programming as a systematic discipline
based on certain fundamental concepts clearly and naturally re ected by the language;
b) to de ne a language whose implementations could be both reliable and ecient on then-
available computers.
However, it has b ecome apparentthatPascal has attributes that go far b eyond these original goals.
It is now b eing increasingly used commercially in the writing of b oth system and application software.
This International Standard is primarily a consequence of the growing commercial interest in Pascal
and the need to promote the p ortabilityofPascal programs b etween data pro cessing systems.
In drafting this International Standard the continued stabilityofPascal has b een a prime ob jective.
However, apart from changes to clarify the sp eci cation, twomajorchanges have b een intro duced.
a) The syntax used to sp ecify pro cedural and functional parameters has b een changed to require
the use of a pro cedure or function heading, as appropriate (see 6.6.3.1); this change was
intro duced to overcome a language insecurity.
b) A fth kind of parameter, the conformant-array-parameter, has b een intro duced (see 6.6.3.7).
With this kind of parameter, the required bounds of the index-typ e of an actual-parameter
are not xed, but are restricted to a sp eci ed range of values.
Pro ject history
In 1977, a working group was formed within the British Standards Institution (BSI) to pro duce a
standard for the programming language Pascal. This group pro duced several working drafts, the
rst draft for public comment b eing widely published early in 1979. In 1978, BSI's prop osal that
Pascal b e added to ISO's program of work was accepted, and the ISO Pascal Working Group (then
designated ISO/TC97/SC5/WG4) was formed in 1979. The Pascal standard was to be published
by BSI on b ehalf of ISO, and this British Standard referenced bytheInternational Standard.
In the USA, in the fall of 1978, application was made to the IEEE Standards Board by the IEEE
Computer So ciety to authorize pro ject 770 (Pascal). After approval, the rst meeting was held in
January 1979.
In Decemb er of 1978, X3J9 convened as a result of a SPARC (Standards Planning and Requirements
Committee) resolution to form a US TAG (Technical Advisory Group) for the ISO Pascal
standardization e ort initiated by the UK. These e orts were p erformed under X3 pro ject 317. v
ISO/IEC 7185:1990(E)
In agreement with IEEE representatives, in February of 1979, an X3 resolution combined the X3J9
and P770 committees into a single committee called the Joint X3J9/IEEE-P770 Pascal Standards
Committee. (Throughout, the term JPC refers to this committee.) The rst meeting as JPC was
held in April 1979.
The resolution to form JPC clari ed the dual function of the single joint committee to pro duce a
dpANS and a prop osed IEEE Pascal standard, identical in content.
ANSI/IEEE770X3.97-1983, American National Standard Pascal Computer Programming Language,
was approved by the IEEE Standards Board on September 17, 1981, and by the American
National Standards Institute on December 16, 1982. British Standard BS6192, Sp eci cation for
Computer programming language Pascal, was published in 1982, and International Standard 7185
(incorp orating BS6192 by reference) was approved by ISO on December 1, 1983. Di erences b etween
the ANSI and ISO standards are detailed in the Foreword of ANSI/IEEE770X3.97-1983.
In 1985, the ISO Pascal Working Group (then designated ISO/TC97/SC22/WG2, now ISO/IEC
JTC1/SC22/WG2) was reconvened after along break. An Interpretations Subgroup was formed,
to interpret doubtful or ambiguous p ortions of the Pascal standards. As a result of the work
of this subgroup, and also of the work on the Extended Pascal standard b eing pro duced by
WG2 and JPC, BS6192/ISO7185 was revised and corrected during 1988/89; it is exp ected that
ANSI/IEEE770X3.97-1983 will b e replaced by the revised ISO 7185.
The ma jor revisions to BS6192:1982 to pro duce the new ISO 7185 are:
a) resolution of the di erences with ANSI/IEEE770X3.97-1983;
b) relaxation of the syntax of real numbers, to allow \digit sequences" rather than \unsigned
integers" for the various comp onents;
c) in the handling of \end-of-line characters" in text les;
d) in the handling of run-time errors. vi
INTERNATIONAL STANDARD ISO/IEC 7185:1990(E)
Information technology | Programming
languages | Pascal
1 Scop e
1.1
This International Standard sp eci es the semantics and syntax of the computer programming
language Pascal by sp ecifying requirements for a pro cessor and for a conforming program. Two
levels of compliance are de ned for b oth pro cessors and programs.
1.2
This International Standard do es not sp ecify
a) the size or complexity of a program and its data that will exceed the capacityofany sp eci c
data pro cessing system or the capacity of a particular pro cessor, nor the actions to b e taken
when the corresp onding limits are exceeded;
b) the minimal requirements of a data pro cessing system that is capable of supp orting an implementation
of a pro cessor for Pascal;
c) the metho d of activating the program-blo ck or the set of commands used to control the
environment in whichaPascal program is transformed and executed;
d) the mechanism by which programs written in Pascal are transformed for use by a data
pro cessing system;
e) the metho d for rep orting errors or warnings;
f ) the typ ographical representation of a program published for human reading.
2 Normative reference
The following standard contains provisions which, through reference in this text, constitute provisions
of this International Standard. At the time of publication, the edition indicated was valid. All
standards are sub ject to revision, and parties to agreements based on this International Standard
are encouraged to investigate the p ossibility of applying the most recent edition of the standard listed
below. Memb ers of IEC and ISO maintain registers of currently valid International Standards.
ISO 646:1983, Information processing|ISO 7-bit coded character set for information interchange. 1
ISO/IEC 7185:1990(E)
3 De nitions
For the purp oses of this International Standard, the following de nitions apply.
NOTE | Todrawattention to language concepts, some terms are printed in italics on their rst mention
or at their de ning o ccurrence(s) in this International Standard.
3.1 Error
A violation by a program of the requirements of this International Standard that a pro cessor is
p ermitted to leave undetected.
NOTES
1 If it is p ossible to construct a program in which the violation or non-violation of this International Standard
requires knowledge of the data read by the program or the implementation de nition of implementation-
de ned features, then violation of that requirement is classi ed as an error. Pro cessors may rep ort on such
violations of the requirement without such knowledge, but there always remain some cases that require
execution, simulated execution, or pro of pro cedures with the required knowledge. Requirements that can
be veri ed without such knowledge are not classi ed as errors.
2 Pro cessors should attempt the detection of as many errors as p ossible, and to as complete a degree as
p ossible. Permission to omit detection is provided for implementations in which the detection would b e an
excessive burden.
3.2 Extension
A mo di cation to clause 6 of the requirements of this International Standard that do es not invalidate
any program complying with this International Standard, as de ned by 5.2, except by prohibiting
the use of one or more particular sp ellings of identi ers (see 6.1.2 and 6.1.3).
3.3 Implementation-de ned
Possibly di ering b etween pro cessors, but de ned for any particular pro cessor.
3.4 Implementation-dep endent
Possibly di ering b etween pro cessors and not necessarily de ned for any particular pro cessor.
3.5 Pro cessor
A system or mechanism that accepts a program as input, prepares it for execution, and executes the
pro cess so de ned with data to pro duce results.
NOTE | A pro cessor may consist of an interpreter, a compiler and run-time system, or another mechanism,
together with an asso ciated host computing machine and op erating system, or another mechanism for
achieving the same e ect. A compiler in itself, for example, do es not constitute a pro cessor. 2
ISO/IEC 7185:1990(E)
Table 1 | Metalanguage symbols
Metasymbol Meaning
= Shall b e de ned to b e
> Shall have as an alternative de nition
| Alternatively
. End of de nition
[ x ] 0 or 1 instance of x
{ x } 0 or more instances of x
( x | y ) Grouping: either of x or y
`xyz' The terminal symbol xyz
meta-identi er A nonterminal symbol
4 De nitional conventions
The metalanguage used in this International Standard to sp ecify the syntax of the constructs is
based on Backus-Naur Form. The notation has b een mo di ed from the original to p ermit greater
convenience of description and to allow for iterative pro ductions to replace recursive ones. Table 1
lists the meanings of the various metasymbols. Further sp eci cation of the constructs is given by
prose and, in some cases, by equivalent program fragments. Any identi er that is de ned in clause
6 as a required identi er shall denote the corresp onding required entity by its o ccurrence in such
a program fragment. In all other resp ects, anysuch program fragment is b ound byany p ertinent
requirement of this International Standard.
A meta-identi er shall b e a sequence of letters and hyphens b eginning with a letter.
A sequence of terminal and nonterminal symb ols in a pro duction implies the concatenation of the
text that they ultimately represent. Within 6.1 this concatenation is direct; no characters shall
intervene. In all other parts of this International Standard the concatenation is in accordance with
the rules set out in 6.1.
The characters required to form Pascal programs shall b e those implicitly required to form the tokens
and separators de ned in 6.1.
Use of the words of, in, containing,andclosest-containing, when expressing a relationship b etween
terminal or nonterminal symb ols, shall have the following meanings
|the x of ay: refers to the x o ccurring directly in a pro duction de ning y;
|the x in ay: is synonymous with `the x of ay';
|a y containing an x: refers to any y from which an x is directly or indirectly derived;
|the y closest-containing an x: that y containing an x and not containing another y containing
that x.
These syntactic conventions are used in clause 6 to sp ecify certain syntactic requirements and also
the contexts within which certain semantic sp eci cations apply.
In addition to the normal English rules for hyphenation, hyphenation is used in this International 3
ISO/IEC 7185:1990(E)
Standard to form comp ound words that represent meta-identi ers, semantic terms, or both. All
meta-identi ers that contain more than one word are written as a unit with hyphens joining the
parts. Semantic terms ending in \typ e" and \variable" are also written as one hyphenated unit.
Semantic terms representing comp ound ideas are likewise written as hyphenated units, e.g., digit-
value, activation-p oint, assignment-compatible, and identifying-value.
NOTES are included in this International Standard only for purp oses of clari cation, and aid in the
use of the standard. NOTES are informative only and are not a part of the International Standard.
Examples in this International Standard are equivalent to NOTES.
5 Compliance
There are two levels of compliance, level 0 and level 1. Level 0 do es not include conformant-array-
parameters. Level 1 do es include conformant-array-parameters.
5.1 Pro cessors
A pro cessor complying with the requirements of this International Standard shall
a) if it complies at level 0, accept all the features of the language sp eci ed in clause 6, except for
6.6.3.6 e), 6.6.3.7,and 6.6.3.8, with the meanings de ned in clause 6;
b) if it complies at level 1, accept all the features of the language sp eci ed in clause 6 with the
meanings de ned in clause 6;
c) not require the inclusion of substitute or additional language elements in a program in order
to accomplish a feature of the language that is sp eci ed in clause 6;
d) b e accompanied by a do cumentthatprovides a de nition of all implementation-de ned features;
e) b e able to determine whether or not the program violates any requirements of this International
Standard, where such a violation is not designated an error, rep ort the result of this determination
to the user of the pro cessor b efore the execution of the program-blo ck, if any, and shall prevent
execution of the program-blo ck, if any;
f ) treat each violation that is designated an error in at least one of the following ways
1) there shall b e a statement in an accompanying do cument that the error is not rep orted,
and a note referencing each such statement shall app ear in a separate section of the
accompanying do cument;
2) the pro cessor shall rep ort the error or the p ossibility of the error during preparation of
the program for execution and in the event of such a rep ort shall be able to continue
further pro cessing and shall b e able to refuse execution of the program-blo ck;
3) the pro cessor shall rep ort the error during execution of the program;
and if an error is rep orted during execution of the program, the pro cessor shall terminate
execution; if an error o ccurs within a statement, the execution of that statement shall not b e 4
ISO/IEC 7185:1990(E)
completed;
NOTE | 1 This means that pro cessing will continue up to or b eyond execution of the program at
the option of the user.
g) b e accompanied by a do cument that separately describ es any features accepted by the pro cessor
that are prohibited or not sp eci ed in clause 6: such extensions shall be describ ed as b eing
`extensions to Pascal as sp eci ed by ISO/IEC 7185';
h) b e able to pro cess, in a manner similar to that sp eci ed for errors, any use of anysuch extension;
i) b e able to pro cess, in a manner similar to that sp eci ed for errors, any use of an implementation-
dep endent feature.
NOTE | 2 The phrase `b e able to' is used in 5.1 to p ermit the implementation of a switch with which the
user may control the rep orting.
A pro cessor that purp orts to comply, wholly or partially, with the requirements of this International
Standard shall do so only in the following terms. A compliance statement shall be pro duced
by the pro cessor as a consequence of using the pro cessor or shall be included in accompanying
do cumentation. If the pro cessor complies in all resp ects with the requirements of this International
Standard, the compliance statementshallbe
hThis processori complies with the requirements of level hnumberi of ISO/IEC 7185.
If the pro cessor complies with some but not all of the requirements of this International Standard
then it shall not use the ab ove statement, but shall instead use the following compliance statement
hThis processori complies with the requirements of level hnumberi of ISO/IEC 7185, with the
following exceptions: hfol lowed by a reference to, or a complete list of, the requirements of the
International Standard with which the processor does not complyi.
In b oth cases the text hThis processori shall b e replaced by an unambiguous name identifying the
pro cessor, and the text hnumberi shall b e replaced by the appropriate level number.
NOTE | 3 Pro cessors that do not comply fully with the requirements of the International Standard are
not required to give full details of their failures to comply in the compliance statement; a brief reference
to accompanying do cumentation that contains a complete list in sucient detail to identify the defects is
sucient.
5.2 Programs
A program conforming with the requirements of this International Standard shall
a) if it conforms at level 0, use only those features of the language sp eci ed in clause 6, except
for 6.6.3.6 e), 6.6.3.7, and 6.6.3.8;
b) if it conforms at level 1, use only those features of the language sp eci ed in clause 6;and
c) not rely on any particular interpretation of implementation-dep endent features.
NOTES 5
ISO/IEC 7185:1990(E)
1 A program that complies with the requirements of this International Standard mayrely on particular
implementation-de ned values or features.
2 The requirements for conforming programs and compliant pro cessors do not require that the results
pro duced by a conforming program are always the same when pro cessed by a compliant pro cessor. They
may b e the same, or they may di er, dep ending on the program. A simple program to illustrate this is
program x(output); begin writeln(maxint) end.
6 Requirements
6.1 Lexical tokens
NOTE | The syntax given in this sub clause describ es the formation of lexical tokens from characters and
the separation of these tokens and therefore do es not adhere to the same rules as the syntax in the rest of
this International Standard.
6.1.1 General
The lexical tokens used to construct Pascal programs are classi ed into sp ecial-symb ols, identi ers,
directives, unsigned-numb ers, lab els, and character-strings. The representation of any letter (upp er
case or lower case, di erences of font, etc.) o ccurring anywhere outside of a character-string (see
6.1.7) shall b e insigni cant in that o ccurrence to the meaning of the program.
letter = `a' j `b' j `c' j `d' j `e' j `f' j `g' j `h' j `i' j `j'
j `k' j `l' j `m' j `n' j `o' j `p' j `q' j `r' j `s' j `t'
j `u' j `v' j `w' j `x' j `y' j `z' .
digit = `0' j `1' j `2' j `3' j `4' j `5' j `6' j `7' j `8' j `9' .
6.1.2 Sp ecial-symbols
The sp ecial-symb ols are tokens having sp ecial meanings and are used to delimit the syntactic units
of the language.
sp ecial-symbol = `+' j ` ' j `*' j `/' j `=' j `<' j `>' j `[' j `]'
j `.' j `,' j `:' j `;' j `"' j `(' j `)'
j `<>' j `<=' j `>=' j `:=' j `..' j word-symbol .
word-symbol = `and' j `array' j `b egin' j `case' j `const' j `div'
j `do' j `downto' j `else' j `end' j ` le' j `for'
j `function' j `goto' j `if' j `in' j `lab el' j `mo d'
j `nil' j `not' j `of' j `or' j `packed' j `pro cedure'
j `program' j `record' j `rep eat' j `set' j `then'
j `to' j `typ e' j `until' j `var' j `while' j `with' . 6
ISO/IEC 7185:1990(E)
6.1.3 Identi ers
Identi ers can b e of any length. The spel ling of an identi er shall b e comp osed from all its constituent
characters taken in textual order, without regard for the case of letters. No identi er shall have the
same sp elling as any word-symbol. Identi ers that are sp eci ed to be required shall have sp ecial
signi cance (see 6.2.2.10 and 6.10).
identi er = letter f letter j digit g .
Examples:
X
time
readinteger
WG4
AlterHeatSetting
InquireWorkstationTransformation
InquireWorkstationIdentification
6.1.4 Directives
A directive shall only o ccur in a pro cedure-declaration or a function-declaration. The only directive
shall be the required directive forward (see 6.6.1 and 6.6.2). No directive shall have the same
sp elling as anyword-symb ol.
directive = letter f letter j digit g .
NOTE | Many pro cessors provide, as an extension, the directive external, which is used to sp ecify that the
pro cedure-blo ck or function-blo ck corresp onding to that pro cedure-heading or function-heading is external
to the program-blo ck. Usually it is in a library in a form to b e input to, or that has b een pro duced by, the
pro cessor.
6.1.5 Numbers
An unsigned-integer shall denote in decimal notation a value of integer-typ e (see 6.4.2.2). An
unsigned-real shall denote in decimal notation a value of real-typ e (see 6.4.2.2). The letter `e'
preceding a scale-factor shall mean times ten to the power of. The value denoted by an unsigned-
integer shall b e in the closed interval0tomaxint (see 6.4.2.2 and 6.7.2.2).
signed-number = signed-integer j signed-real .
signed-real = [ sign ] unsigned-real .
signed-integer = [ sign ] unsigned-integer .
unsigned-number = unsigned-integer j unsigned-real .
sign = `+' j ` ' . 7
ISO/IEC 7185:1990(E)
unsigned-real = digit-sequence `.' fractional-part [ `e' scale-factor ]
j digit-sequence `e' scale-factor .
unsigned-integer = digit-sequence .
fractional-part = digit-sequence .
scale-factor = [ sign ] digit-sequence .
digit-sequence = digit f digit g . 8
ISO/IEC 7185:1990(E)
Examples:
1e10
1
+100
-0.1
5e-3
87.35E+8
6.1.6 Lab els
Lab els shall b e digit-sequences and shall b e distinguished by their apparentintegral values and shall
b e in the closed interval0to9999. The spel ling of a lab el shall b e its apparentintegral value.
lab el = digit-sequence .
6.1.7 Character-strings
Acharacter-string containing a single string-element shall denote a value of the required char-typ e
(see 6.4.2.2). A character-string containing more than one string-element shall denote a value of
a string-typ e (see 6.4.3.2)with the same number of comp onents as the character-string contains
string-elements. All character-strings with a given number of comp onents shall p ossess the same
string-typ e.
There shall b e an implementation-de ned one-to-one corresp ondence b etween the set of alternatives
from which string-elements are drawn and a subset of the values of the required char-typ e. The
o ccurrence of a string-element in acharacter-string shall denote the o ccurrence of the corresp onding
value of char-typ e.
character-string = `'' string-element f string-element g `'' .
string-element = ap ostrophe-image j string-character .
ap ostrophe-image = `"' .
string-character = one-of-a-set-of-implementation-de ned-characters .
NOTE | Conventionally, the ap ostrophe-image is regarded as a substitute for the ap ostrophe character,
which cannot b e a string-character.
Examples:
'A'
';'
''''
'Pascal'
'THIS IS A STRING' 9
ISO/IEC 7185:1990(E)
6.1.8 Token separators
Where a commentary shall b e any sequence of characters and separations of lines, containing neither
g nor *), the construct
(`f' j `(*' ) commentary ( `*)' j `g')
shall b e a comment if neither the f nor the (* o ccurs within a character-string or within a commentary.
NOTES
1 A commentmaythus commence with { and end with *), or commence with (* and end with }.
2 The sequence (*) cannot o ccur in a commentary even though the sequence {) can.
Comments, spaces (except in character-strings), and the separations of consecutive lines shall be
considered to be token separators. Zero or more token separators can o ccur between any two
consecutivetokens, b efore the rst token of a program text, or after the last token of the program
text. There shall be at least one separator between any pair of consecutive tokens made up of
identi ers, word-symb ols, lab els or unsigned-numbers. No separators shall o ccur within tokens.
6.1.9 Lexical alternatives
The representation for lexical tokens and separators given in 6.1.1 to 6.1.8, except for the character
sequences (* and *), shall constitute a referencerepresentation for these tokens and separators.
To facilitate the use of Pascal on pro cessors that do not supp ort the reference representation, the
following alternatives have b een de ned. All pro cessors that have the required characters in their
character set shall provide both the reference representations and the alternative representations,
and the corresp onding tokens or separators shall not be distinguished. Provision of the reference
representations, and of the alterativetoken @, shall b e implementation-de ned.
The alternative representations for the tokens shall b e
Reference token Alternativetoken
" @
[ (.
] .)
NOTE | 1 The character " that app ears in some national variants of ISO 646 is regarded as identical to the
character ^. In this International Standard, the character " has b een used b ecause of its greater visibility.
The comment-delimiting characters f and g shall be the reference representations, and (* and *)
resp ectively shall b e alternative representations (see 6.1.8).
NOTE | 2 See also 1.2 f ). 10
ISO/IEC 7185:1990(E)
6.2 Blo cks, scop es, and activations
6.2.1 Blo cks
A blo ck closest-containing a lab el-declaration-part in which a lab el o ccurs shall closest-contain exactly
one statement in whichthatlabeloccurs. The o ccurrence of a lab el in the lab el-declaration-part of
ablock shall b e its de ning-p oint for the region that is the blo ck. Each applied o ccurrence of that
lab el (see 6.2.2.8) shall be a lab el. Within an activation of the blo ck, all applied o ccurrences of
that lab el shall denote the corresp onding program-p oint in the algorithm of the activationatthat
statement (see 6.2.3.2 b)).
blo ck = lab el-declaration-part constant-de nition-part typ e-de nition-part
variable-declaration-part pro cedure-and-function-declaration-part
statement-part .
lab el-declaration-part = [ `lab el' lab el f `,' lab el g `;' ] .
constant-de nition-part = [ `const' constant-de nition `;' f constant-de nition `;' g ] .
typ e-de nition-part = [ `typ e'typ e-de nition `;' f typ e-de nition `;' g ] .
variable-declaration-part = [ `var'variable-declaration `;' f variable-declaration `;' g ] .
pro cedure-and-function-declaration-part = f ( pro cedure-declaration
j function-declaration )`;' g .
The statement-part shall sp ecify the algorithmic actions to b e executed up on an activation of the
blo ck.
statement-part = comp ound-statement .
6.2.2 Scop es
6.2.2.1
Eachidenti er or lab el contained by the program-blo ck shall have a de ning-p oint.
6.2.2.2
Each de ning-p oint shall havea region that is a part of the program text, and a scop e that is a part
or all of that region.
6.2.2.3
The region of each de ning-p oint is de ned elsewhere (see 6.2.1, 6.2.2.10, 6.3, 6.4.1, 6.4.2.3,
6.4.3.3, 6.5.1, 6.5.3.3, 6.6.1, 6.6.2, 6.6.3.1, 6.8.3.10, 6.10). 11
ISO/IEC 7185:1990(E)
6.2.2.4
The scop e of each de ning-p oint shall b e its region (including all regions enclosed by that region)
sub ject to 6.2.2.5 and 6.2.2.6.
6.2.2.5
When an identi er or lab el has a de ning-p oint for region A and another identi er or lab el having
the same sp elling has a de ning-p oint for some region B enclosed by A, then region B and all regions
enclosed by B shall b e excluded from the scop e of the de ning-p oint for region A.
6.2.2.6
The region that is the eld-sp eci er of a eld-designator shall b e excluded from the enclosing scop es.
6.2.2.7
When an identi er or lab el has a de ning-p oint for a region, another identi er or lab el with the
same sp elling shall not have a de ning-p oint for that region.
6.2.2.8
Within the scop e of a de ning-p oint of an identi er or lab el, each o ccurrence of an identi er or lab el
having the same sp elling as the identi er or lab el of the de ning-p oint shall b e designated an applied
occurrence of the identi er or lab el of the de ning-p oint, except for an o ccurrence that constituted
the de ning-p oint; such an o ccurrence shall be designated a de ning occurrence. No o ccurrence
outside that scop e shall b e an applied o ccurrence.
NOTE | Within the scop e of a de ning-p oint of an identi er or lab el, there are no applied o ccurrences of
an identi er or lab el that cannot b e distinguished from it and have a de ning-p oint for a region enclosing
that scop e.
6.2.2.9
The de ning-p oint of an identi er or lab el shall precede all applied o ccurrences of that identi er
or lab el contained by the program-blo ck with one exception, namely that an identi er can havean
applied o ccurrence in the typ e-identi er of the domain-typ e of any new-p ointer-typ es contained by
the typ e-de nition-part containing the de ning-p oint of the typ e-identi er.
6.2.2.10
Required identi ers that denote required values, typ es, pro cedures, and functions shall b e used as if
their de ning-p oints have a region enclosing the program (see 6.1.3, 6.3, 6.4.1, and 6.6.4.1).
NOTE | The required identi ers input and output are not included, since these denote variables. 12
ISO/IEC 7185:1990(E)
6.2.2.11
Whatever an identi er or lab el denotes at its de ning-p oint shall b e denoted at all applied o ccurrences
of that identi er or lab el.
NOTES
1 Within syntax de nitions, an applied o ccurrence of an identi er is quali ed (e.g., typ e-identi er), whereas
a use that constitutes a de ning-p oint is not quali ed.
2Itisintended that such quali cation indicates the nature of the entity denoted by the applied o ccurrence:
e.g., a constant-identi er denotes a constant.
6.2.3 Activations
6.2.3.1
A pro cedure-identi er or function-identi er having a de ning-p oint for a region that is a blo ck within
the pro cedure-and-function-declaration-part of that blo ck shall b e designated local to that blo ck.
6.2.3.2
The activation of a blo ck shall contain
a) for the statement-part of the blo ck, an algorithm, the completion of which shall terminate the
activation (see also 6.8.2.4);
b) for each de ning-p oint of a lab el in the lab el-declaration-part of the blo ck, a corresp onding
program-p oint (see 6.2.1);
c) for eachvariable-identi er having a de ning-p oint for the region that is the blo ck, a variable
p ossessing the typ e asso ciated with the variable-identi er;
d) for each pro cedure-identi er lo cal to the blo ck, a pro cedure with the pro cedure-blo ck corresp onding
to the pro cedure-identi er, and the formal-parameters of that pro cedure-blo ck;
e) for each function-identi er lo cal to the blo ck, a function with the function-blo ck corresp onding
to, and the result typ e asso ciated with, the function-identi er, and the formal-parameters of
that function-blo ck;
f ) if the blo ck is a function-blo ck, a result p ossessing the asso ciated result typ e.
NOTE | Each activation contains its own algorithm, program-p oints, variables, pro cedures, and functions,
distinct from every other activation.
6.2.3.3
The activation of a pro cedure or function shall b e an activation of the blo ck of the pro cedure-blo ck
of the pro cedure or function-blo ck of the function, resp ectively, and shall b e designated as within
a) the activation containing the pro cedure or function; and 13
ISO/IEC 7185:1990(E)
b) all activations that that containing activation is within.
NOTE | An activation of a blo ck B can only be within activations of blo cks containing B. Thus, an
activation is not within another activation of the same blo ck.
Within an activation, an applied o ccurrence of a lab el or variable-identi er, or of a pro cedure-
identi er or function-identi er lo cal to the blo ckofthe activation, shall denote the corresp onding
program-p oint, variable, pro cedure, or function, resp ectively, of that activation; except that the
function-identi er of an assignment-statement shall, within an activation of the function denoted by
that function-identi er, denote the result of that activation.
6.2.3.4
A pro cedure-statement or function-designator contained in the algorithm of an activation and that
sp eci es an activation of a blo ck shall be designated the activation-point of the activation of the
blo ck.
6.2.3.5
All variables contained by an activation, except for those listed as program-parameters, and any
result of an activation, shall be totally-unde ned at the commencement of that activation. The
algorithm, program-p oints, variables, pro cedures, and functions, if any, shall exist until the termination
of the activation.
6.3 Constant-de nitions
A constant-de nition shall intro duce an identi er to denote a value.
constant-de nition = identi er `='constant .
constant = [ sign ]( unsigned-number j constant-identi er )
j character-string .
constant-identi er = identi er .
The o ccurrence of an identi er in aconstant-de nition of aconstant-de nition-part of a blo ck shall
constitute its de ning-p oint for the region that is the blo ck. The constant in a constant-de nition
shall not contain an applied o ccurrence of the identi er in the constant-de nition. Each applied
o ccurrence of that identi er shall b e a constant-identi er and shall denote the value denoted by the
constant of the constant-de nition. A constant-identi er in a constant containing an o ccurrence
of a sign shall have been de ned to denote a value of real-typ e or of integer-typ e. The required
constant-identi ers shall b e as sp eci ed in 6.4.2.2 and 6.7.2.2. 14
ISO/IEC 7185:1990(E)
6.4 Typ e-de nitions
6.4.1 General
Atyp e-de nition shall intro duce an identi er to denote a typ e. Typ e shall b e an attribute that is
p ossessed byevery value and every variable. Each o ccurrence of a new-typ e shall denote a typ e that
is distinct from any other new-typ e.
typ e-de nition = identi er `='typ e-denoter .
typ e-denoter = typ e-identi er j new-typ e .
new-typ e = new-ordinal-typ e j new-structured-typ e j new-p ointer-typ e .
The o ccurrence of an identi er in atyp e-de nition of atyp e-de nition-part of a blo ck shall constitute
its de ning-p oint for the region that is the blo ck. Each applied o ccurrence of that identi er shall
be a typ e-identi er and shall denote the same typ e as that which is denoted by the typ e-denoter of
the typ e-de nition. Except for applied o ccurrences in the domain-typ e of a new-p ointer-typ e, the
typ e-denoter shall not contain an applied o ccurrence of the identi er in the typ e-de nition.
Typ es shall be classi ed as simple-typ es, structured-typ es or pointer-typ es. The required typ e-
identi ers and corresp onding required typ es shall b e as sp eci ed in 6.4.2.2 and 6.4.3.5.
simple-typ e-identi er = typ e-identi er .
structured-typ e-identi er = typ e-identi er .
p ointer-typ e-identi er = typ e-identi er .
typ e-identi er = identi er .
A typ e-identi er shall be considered as a simple-typ e-identi er, a structured-typ e-identi er, or a
pointer-typ e-identi er, according to the typ e that it denotes.
6.4.2 Simple-typ es
6.4.2.1 General
A simple-typ e shall determine an ordered set of values. A value of an ordinal-typ e shall havean
integer ordinal numb er; the ordering relationship b etween anytwosuchvalues of one typ e shall b e the
same as that b etween their ordinal numb ers. An ordinal-typ e-identi er shall denote an ordinal-typ e.
Areal-typ e-identi er shall denote the real-typ e.
simple-typ e = ordinal-typ e j real-typ e-identi er .
ordinal-typ e = new-ordinal-typ e j ordinal-typ e-identi er .
new-ordinal-typ e = enumerated-typ e j subrange-typ e .
ordinal-typ e-identi er = typ e-identi er . 15
ISO/IEC 7185:1990(E)
real-typ e-identi er = typ e-identi er .
6.4.2.2 Required simple-typ es
The following typ es shall exist
a) integer-type. The required typ e-identi er integer shall denote the integer-typ e. The integer-
typ e shall be an ordinal-typ e. The values shall be a subset of the whole numbers, denoted
as sp eci ed in 6.1.5 by signed-integer (see also 6.7.2.2). The ordinal number of a value of
integer-typ e shall b e the value itself.
b) real-type. The required typ e-identi er real shall denote the real-typ e. The real-typ e shall
b e a simple-typ e. The values shall b e an implementation-de ned subset of the real numb ers,
denoted as sp eci ed in 6.1.5 by signed-real.
c) Boolean-type. The required typ e-identi er Bo olean shall denote the Bo olean-typ e. The
Bo olean-typ e shall b e an ordinal-typ e. The values shall be the enumeration of truth values
denoted by the required constant-identi ers false and true,suchthat false is the predecessor
of true. The ordinal numbers of the truth values denoted by false and true shall be the
integer values 0 and 1 resp ectively.
d) char-type. The required typ e-identi er char shall denote the char-typ e. The char-typ e
shall be an ordinal-typ e. The values shall be the enumeration of a set of implementation-
de ned characters, some p ossibly without graphic representations. The ordinal numbers of
the character values shall b e values of integer-typ e that are implementation-de ned and that
are determined by mapping the character values on to consecutive non-negativeinteger values
starting at zero. The following relations shall hold.
1) The subset of character values representing the digits 0 to 9 shall b e numerically ordered
and contiguous.
2) The subset of character values representing the upp er case letters A to Z, if available,
shall b e alphab etically ordered but not necessarily contiguous.
3) The subset of character values representing the lower case letters a to z, if available, shall
b e alphab etically ordered but not necessarily contiguous.
NOTE | Op erators applicable to the required simple-typ es are sp eci ed in 6.7.2.
6.4.2.3 Enumerated-typ es
enumerated-typ e = `('identi er-list `)' .
identi er-list = identi er f `,' identi er g .
The o ccurrence of an identi er in the identi er-list of an enumerated-typ e shall constitute its
de ning-p oint for the region that is the blo ck closest-containing the enumerated-typ e. Each applied
o ccurrence of the identi er shall be a constant-identi er. Within an activation of the blo ck, all
applied o ccurrences of that identi er shall p ossess the typ e denoted by the enumerated-typ e and 16
ISO/IEC 7185:1990(E)
shall denote the typ e's value whose ordinal number is the number of o ccurrences of identi ers
preceding that identi er in the identi er-list.
NOTE | Enumerated typ e constants are ordered by the sequence in which they are de ned, and they have
consecutive ordinal numb ers starting at zero.
Examples:
(red, yellow, green, blue, tartan)
(club, diamond, heart, spade)
(married, divorced, widowed, single)
(scanning, found, notpresent)
(Busy, InterruptEnable, ParityError, OutOfPaper, LineBreak)
6.4.2.4 Subrange-typ es
A subrange-typ e shall include identi cation of the smallest and the largest value in the subrange.
The rst constant of a subrange-typ e shall sp ecify the smallest value, and this shall b e less than or
equal to the largest value, which shall b e sp eci ed by the second constant of the subrange-typ e. Both
constants shall b e of the same ordinal-typ e, and that ordinal-typ e shall b e designated the host-type
of the subrange-typ e.
subrange-typ e = constant`..' constant .
Examples:
1..100
-10..+10
red..green
'0'..'9'
6.4.3 Structured-typ es
6.4.3.1 General
A new-structured-typ e shall b e classi ed as an array-typ e, record-typ e, set-typ e, or le-typ e according
to the unpacked-structured-typ e closest-contained by the new-structured-typ e. A comp onent of a
value of a structured-typ e shall b e a value.
structured-typ e = new-structured-typ e j structured-typ e-identi er .
new-structured-typ e = [ `packed' ] unpacked-structured-typ e .
unpacked-structured-typ e = array-typ e j record-typ e j set-typ e j le-typ e .
The o ccurrence of the token packed in a new-structured-typ e shall designate the typ e denoted
therebyaspacked. The designation of a structured-typ e as packed shall indicate to the pro cessor
that data-storage of values should b e economized, even if this causes op erations on, or accesses to
comp onents of, variables p ossessing the typetobelessecient in terms of space or time.
The designation of a structured-typ e as packed shall a ect the representation in data-storage of 17
ISO/IEC 7185:1990(E)
that structured-typ e only; i.e., if a comp onent is itself structured, the comp onent's representation
in data-storage shall b e packed only if the typ e of the comp onent is designated packed.
NOTE | The ways in which the treatmentofentities of a typ e is a ected by whether or not the typ e is
designated packed are sp eci ed in 6.4.3.2, 6.4.5, 6.6.3.3, 6.6.3.8, 6.6.5.4, and 6.7.1.
6.4.3.2 Array-typ es
An array-typ e shall be structured as a mapping from each value sp eci ed by its index-typ e to
a distinct comp onent. Each comp onent shall have the typ e denoted by the typ e-denoter of the
comp onent-typ e of the array-typ e.
array-typ e = `array'`[' index-typ e f `,' index-typ e g `]'`of' comp onent-typ e .
index-typ e = ordinal-typ e .
comp onent-typ e = typ e-denoter .
Example 1:
array [1..100] of real
array [Boolean] of colour
An array-typ e that sp eci es a sequence of two or more index-typ es shall b e an abbreviated notation
foranarray-typ e sp eci ed to have as its index-typ e the rst index-typ e in the sequence and to havea
comp onent-typ e that is an array-typ e sp ecifying the sequence of index-typ es without the rst index-
typ e in the sequence and sp ecifying the same comp onent-typ e as the original sp eci cation. The
comp onent-typ e thus constructed shall b e designated packed if and only if the original array-typ e is
designated packed. The abbreviated form and the full form shall b e equivalent.
NOTE | 1 Eachofthefollowing two examples thus contains di erentways of expressing its array-typ e.
Example 2:
array [Boolean] of array [1..10] of array [size] of real
array [Boolean] of array [1..10, size] of real
array [Boolean, 1..10, size] of real
array [Boolean, 1..10] of array [size] of real
Example 3:
packed array [1..10, 1..8] of Boolean
packed array [1..10] of packed array [1..8] of Boolean
Let i denote a value of the index-typ e; let V denote a value of that comp onent of the array-typ e
i
that corresp onds to the value i by the structure of the array-typ e; let the smallest and largest values
sp eci ed by the index-typ e be denoted by m and n, resp ectively; and let k = (ord(n)-ord(m)+1)
denote the number of values sp eci ed by the index-typ e; then the values of the array-typ e shall b e
the distinct k-tuples of the form
(V ,...,V ).
m n 18
ISO/IEC 7185:1990(E)
NOTE | 2 A valueofanarray-typ e do es not therefore exist unless all of its comp onent-values are de ned.
If the comp onent-typ e has c values, then it follows that the cardinality of the set of values of the array-typ e
is c raised to the p ower k.
Anytyp e designated packed and denoted byanarray-typ e having as its index-typ e a denotation of
a subrange-typ e sp ecifying a smallest value of 1 and a largest value of greater than 1, and having as
its comp onent-typ e a denotation of the char-typ e, shall b e designated a string-type.
The corresp ondence of character-strings to values of string-typ es is obtained by relating the individual
string-elements of the character-string, taken in textual order, to the comp onents of the values of
the string-typ e in order of increasing index.
NOTE | 3 The values of a string-typ e p ossess additional prop erties whichallow writing them to text les
(see 6.9.3.6) and de ne their use with relational-op erators (see 6.7.2.5).
6.4.3.3 Record-typ es
The structure and values of a record-typ e shall b e the structure and values of the eld-list of the
record-typ e.
record-typ e = `record' eld-list `end' .
eld-list = [ ( xed-part [ `;'variant-part ] j variant-part )[ `;' ] ] .
xed-part = record-section f `;' record-section g .
record-section = identi er-list `:' typ e-denoter .
eld-identi er = identi er .
variant-part = `case'variant-selector `of'variant f `;'variant g .
variant-selector = [ tag- eld `:' ] tag-typ e .
tag- eld = identi er .
variant = case-constant-list `:' `(' eld-list `)' .
tag-typ e = ordinal-typ e-identi er .
case-constant-list = case-constant f `,' case-constant g .
case-constant = constant .
A eld-list containing neither a xed-part nor a variant-part shall havenocomponents, shall de ne
a single null value, and shall b e designated empty.
The o ccurrence of an identi er in the identi er-list of a record-section of a xed-part of a eld-list
shall constitute its de ning-p oint as a eld-identi er for the region that is the record-typ e closest-
containing the eld-list and shall asso ciate the eld-identi er with a distinct comp onent, which shall
b e designated a eld, of the record-typ e and of the eld-list. That comp onent shall have the typ e 19
ISO/IEC 7185:1990(E)
denoted by the typ e-denoter of the record-section.
The eld-list closest-containing a variant-part shall have a distinct comp onent that shall have the
values and structure de ned by the variant-part.
Let V denote the value of the i-th comp onent of a non-empty eld-list having m comp onents; then
i
the values of the eld-list shall b e distinct m-tuples of the form
(V ,V ,...,V ).
1 2 m
NOTE | 1 If the typeofthei-th comp onent has F values, then the cardinality of the set of values of the
i
eld-list is (F *F *... *F ).
1 2 m
Atag-typ e shall b e the typ e denoted by the ordinal-typ e-identi er of the tag-typ e. A case-constant
shall denote the value denoted by the constant of the case-constant.
The typ e of each case-constant in the case-constant-list of a variant of a variant-part shall be
compatible with the tag-typ e of the variant-selector of the variant-part. The values denoted by
all case-constantsofatyp e that is required to b e compatible with a given tag-typ e shall b e distinct
and the set thereof shall b e equal to the set of values sp eci ed by the tag-typ e. The values denoted
by the case-constants of the case-constant-list of a variant shall b e designated as corresp onding to
the variant.
With each variant-part shall be asso ciated a typ e designated the selector-type p ossessed by the
variant-part. If the variant-selector of the variant-part contains a tag- eld, or if the case-constant-
list of eachvariant of the variant-part contains only one case-constant, then the selector-typ e shall
be denoted by the tag-typ e, and each variant of the variant-part shall be asso ciated with those
values sp eci ed by the selector-typ e denoted bythe case-constants of the case-constant-list of the
variant. Otherwise, the selector-typ e p ossessed bythevariant-part shall b e a new ordinal-typ e that
is constructed to p ossess exactly one value for eachvariant of the variant-part, and no others, and
eachsuchvariant shall b e asso ciated with a distinct value of that typ e.
Eachvariant-part shall have a comp onentwhich shall b e designated the selector of the variant-part,
and which shall p ossess the selector-typ e of the variant-part. If the variant-selector of the variant-part
contains a tag- eld, then the o ccurrence of an identi er in the tag- eld shall constitute the de ning-
point of the identi er as a eld-identi er for the region that is the record-typ e closest-containing the
variant-part and shall asso ciate the eld-identi er with the selector of the variant-part. The selector
shall b e designated a eld of the record-typ e if and only if it is asso ciated with a eld-identi er.
Eachvariant of avariant-part shall denote a distinct comp onent of the variant-part; the comp onent
shall have the values and structure of the eld-list of the variant, and shall b e asso ciated with those
values sp eci ed by the selector-typ e p ossessed bythevariant-part asso ciated with the variant. The
value of the selector of the variant-part shall cause the asso ciated variant and comp onent of the
variant-part to b e in a state that shall b e designated active.
The values of a variant-part shall b e the distinct pairs
(k ,X )
k
where k represents a value of the selector of the variant-part, and X is a value of the eld-list of
k 20
ISO/IEC 7185:1990(E)
the activevariantofthevariant-part.
NOTES
2 If there are n values sp eci ed by the selector-typ e, and if the eld-list of the variant asso ciated with the
i-th value has T values, then the cardinalityofthesetofvalues of the variant-part is (T +T +... +
i 1 2
T ). There is no comp onentof a value of a variant-part corresp onding to any non-active variantof the
n
variant-part.
3 Restrictions placed on the use of elds of a record-variable p ertaining to variant-parts are sp eci ed in
6.5.3.3, 6.6.3.3, and 6.6.5.3.
Examples:
record
year : 0..2000;
month : 1..12;
day : 1..31
end
record
name, firstname : string;
age : 0..99;
case married : Boolean of
true : (Spousesname : string);
false : ( )
end
record
x, y : real;
area : real;
case shape of
triangle :
(side : real; inclination, angle1, angle2 : angle);
rectangle :
(side1, side2 : real; skew : angle);
circle :
(diameter : real);
end
6.4.3.4 Set-typ es
Aset-typ e shall determine the set of values that is structured as the p ower set of the base-typ e of
the set-typ e. Thus, eachvalue of a set-typ e shall b e a set whose memb ers shall b e unique values of
the base-typ e.
set-typ e = `set'`of' base-typ e .
base-typ e = ordinal-typ e . 21
ISO/IEC 7185:1990(E)
NOTE | 1 Op erators applicable to values of set-typ es are sp eci ed in 6.7.2.4.
Examples:
set of char
set of (club, diamond, heart, spade)
NOTE | 2 If the base-typ e of a set-typ e has b values, then the cardinalityofthesetofvalues is 2 raised
to the p ower b.
For each ordinal-typ e T that is not a subrange-typ e, there shall exist b oth an unpacked set-
typ e designated the unpacked-canonical-set-of-T-type andapacked set-typ e designated the packed-
canonical-set-of-T-type. If S is any subrange-typ e and T is its host-typ e, then the set of values
determined bythetyp e set of S shall b e included in the sets of values determined by the unpacked-
canonical-set-of-T-typ e and by the packed-canonical-set-of-T-typ e (see 6.7.1).
6.4.3.5 File-typ es
NOTE | 1 A le-typ e describ es sequences of values of the sp eci ed comp onent-typ e, together with a current
p osition in each sequence and a mo de that indicates whether the sequence is b eing insp ected or generated.
le-typ e = ` le'`of' comp onent-typ e .
A typ e-denoter shall not b e p ermissible as the comp onent-typ e of a le-typ e if it denotes either a
le-typ e or a structured-typ e having any comp onent whose typ e-denoter is not p ermissible as the
comp onent-typ e of a le-typ e.
Examples:
file of real
file of vector
A le-typ e shall de ne implicitly a typ e designated a sequence-type having exactly those values,
which shall b e designated sequences, de ned by the following ve rules in items a) to e).
NOTE | 2 The notation x~y represents the concatenation of sequences x and y. The explicit representation
of sequences (e.g., S(c)), of concatenation of sequences; of the rst, last, and rest selectors; and of sequence
equality is not part of the Pascal language. These notations are used to de ne le values, b elow, and the
required le op erations in 6.6.5.2 and 6.6.6.5.
a) S( ) shall b e a value of the sequence-typ e S and shall b e designated the empty sequence. The
empty sequence shall havenocomponents.
b)Letcbeavalue of the sp eci ed comp onent-typ e and let x b e a value of the sequence-typ e S;
then S(c) shall b e a sequence of typ e S, consisting of the single comp onent-value c, and b oth
S(c)~x and x~S(c) shall b e sequences, distinct from S( ), of typ e S.
c) Let c, S, and x be as in b), let y denote the sequence S(c)~x and let z denote the sequence
x~S(c); then the notation y. rst shall denote c (i.e., the rst comp onent-value of y), y.rest shall
denote x (i.e., the sequence obtained from y by deleting the rst comp onent), and z.last shall
denote c (i.e., the last comp onent-value of z). 22
ISO/IEC 7185:1990(E)
d) Let x and y each b e a non-empty sequence of typ e S; then x = y shall b e true if and only if
b oth (x. rst = y. rst) and (x.rest = y.rest) are true. If x or y is the empty sequence, then x
= y shall b e true if and only if b oth x and y are the empty sequence.
e) Let x, y, and z b e sequences of typ e S; then x ~(y ~z) = (x~y)~z, S( )~x = x, and x~S( ) = x
shall b e true.
A le-typ e also shall de ne implicitly a typ e designated a mode-type having exactly twovalues, which
are designated Inspection and Generation.
NOTE | 3 The explicit denotation of the values Insp ection and Generation is not part of the Pascal language.
A le-typ e shall b e structured as three comp onents. Two of these comp onents, designated f.L and
f.R, shall be of the implicit sequence-typ e. The third comp onent, designated f.M, shall be of the
implicit mo de-typ e.
Let f.L and f.R each be a single value of the sequence-typ e and let f.M be a single value of the
mo de-typ e; then eachvalue of the le-typ e shall b e a distinct triple of the form
(f.L, f.R, f.M)
where f.R shall b e the empty sequence if f.M is the value Generation. The value, f, of the le-typ e
shall b e designated empty if and only if f.L~f.R is the empty sequence.
NOTE | 4 The two comp onents, f.L and f.R, of a value of the le-typ e may b e considered to represent the
single sequence f.L ~f.R together with a current p osition in that sequence. If f.R is non-empty, then f.R. rst
maybe considered the current comp onentas determined bythe current p osition; otherwise, the current
p osition is the end-of- le p osition.
There shall be a le-typ e that is denoted by the required structured-typ e-identi er text. The
structure of the typ e denoted by text shall de ne an additional sequence-typ e whose values shall b e
designated lines. A line shall b e a sequence cs ~S(end-of-line), where cs is a sequence of comp onents
p ossessing the char-typ e, and end-of-line shall represent a sp ecial comp onent-value. Any assertion
in clause 6 that the end-of-line value is attributed to a variable other than a comp onent of a sequence
shall b e construed as an assertion that the variable has attributed to it the char-typ e value space.
If l is a line, then no comp onent of l other than l.last shall be an end-of-line. There shall be an
implementation-de ned subset of the set of char-typ e values, designated characters prohibitedfrom
text les; the e ect of causing a character in that subset to b e attributed to a comp onent of either
t.Lort.Rforany text le t shall b e implementation-dep endent.
A line-sequence, ls, shall b e either the empty sequence or the sequence l ~ ls' where l is a line and
ls' is a line-sequence.
Every value t of the typ e denoted by text shall satisfy the following two rules:
a) If t.M = Insp ection, then t.L ~t.R shall b e a line-sequence.
b) If t.M = Generation, then t.L ~t.R shall be ls ~cs, where ls is a line-sequence and cs is a
sequence of comp onents p ossessing the char-typ e. 23
ISO/IEC 7185:1990(E)
NOTE | 5 In rule b), cs may b e considered, esp ecially if it is non-empty, to b e a partial line that is b eing
generated. Such a partial line cannot o ccur during insp ection of a le. Also, cs do es not corresp ond to t.R,
since t.R is the empty sequence if t.M = Generation.
Avariable that p ossesses the typ e denoted by the required typ e-identi er text shall b e designated
a text le.
NOTE | 6 All required pro cedures and functions applicable to a variable of typ e le of char are applicable
to text les. Additional required pro cedures and functions, applicable only to text les, are de ned in 6.6.6.5
and 6.9.
6.4.4 Pointer-typ es
The values of a p ointer-typ e shall consist of a single nil-value and a set of identifying-values each
identifying a distinct variable p ossessing the domain-typ e of the new-p ointer-typ e. The set of
identifying-values shall b e dynamic, in that the variables and the values identifying them shall b e
p ermitted to b e created and destroyed during the execution of the program. Identifying-values and
the variables identi ed by them shall b e created only by the required pro cedure new (see 6.6.5.3).
NOTE | 1 Since the nil-value is not an identifying-value, it do es not identify a variable.
The token nil shall denote the nil-value in all p ointer-typ es.
pointer-typ e = new-p ointer-typ e j pointer-typ e-identi er .
new-p ointer-typ e = `"' domain-typ e .
domain-typ e = typ e-identi er .
NOTE | 2 The token nil do es not have a single typ e, but assumes a suitable p ointer-typ e to satisfy the
assignment-compatibility rules, or the compatibility rules for op erators, if p ossible.
6.4.5 Compatible typ es
Typ es T1 and T2 shall b e designated compatible if any of the following four statements is true:
a) T1 and T2 are the same typ e.
b) T1 is a subrange of T2, or T2 is a subrange of T1, or b oth T1 and T2 are subranges of the
same host-typ e.
c) T1 and T2 are set-typ es of compatible base-typ es, and either b oth T1 and T2 are designated
packed or neither T1 nor T2 is designated packed.
d) T1 and T2 are string-typ es with the same number of components.
6.4.6 Assignment-compatibility
Avalue of typ e T2 shall b e designated assignment-compatible with a typeT1ifany of the following
ve statements is true: 24
ISO/IEC 7185:1990(E)
a) T1 and T2 are the same typ e, and that typ e is p ermissible as the comp onent-typ e of a le-typ e
(see 6.4.3.5).
b) T1 is the real-typ e and T2 is the integer-typ e.
c) T1 and T2 are compatible ordinal-typ es, and the value of typ e T2 is in the closed interval
sp eci ed by the typ e T1.
d) T1 and T2 are compatible set-typ es, and all the memb ers of the value of typ e T2 are in the
closed interval sp eci ed by the base-typ e of T1.
e) T1 and T2 are compatible string-typ es.
Atany place where the rule of assignment-compatibility is used
a) it shall b e an error if T1 and T2 are compatible ordinal-typ es and the value of typ e T2 is not
in the closed interval sp eci ed bythetyp e T1;
b) it shall b e an error if T1 and T2 are compatible set-typ es and any memberofthevalue of typ e
T2 is not in the closed interval sp eci ed by the base-typ e of the typ e T1.
Atany place where the rule of assignment-compatibility is used to require a value of integer-typ e to
b e assignment-compatible with a real-typ e, an implicit integer-to-real conversion shall b e p erformed.
6.4.7 Example of atyp e-de nition-part
type
natural = 0..maxint;
count = integer;
range = integer;
colour = (red, yellow, green, blue);
sex = (male, female);
year = 1900..1999;
shape = (triangle, rectangle, circle);
punchedcard = array [1..80] of char;
charsequence = file of char;
polar = record
r : real;
theta : angle
end;
indextype = 1..limit;
vector = array [indextype] of real;
person = " persondetails;
persondetails = record
name, firstname : charsequence;
age : natural;
married : Boolean; 25
ISO/IEC 7185:1990(E)
father, child, sibling : person;
case s : sex of
male :
(enlisted, bearded : Boolean);
female :
(mother, programmer : Boolean)
end;
FileOfInteger = file of integer;
NOTE | In the ab ove example count, range, and integer denote the same typ e. The typ es denoted by
year and natural are compatible with, but not the same as, the typ e denoted by range, count,andinteger.
6.5 Declarations and denotations of variables
6.5.1 Variable-declarations
Avariable shall b e an entity to whichavalue can b e attributed (see 6.8.2.2). Eachidenti er in the
identi er-list of avariable-declaration shall denote a distinct variable p ossessing the typ e denoted
bythetyp e-denoter of the variable-declaration.
variable-declaration = identi er-list `:' typ e-denoter .
The o ccurrence of an identi er in the identi er-list of avariable-declaration of the variable-declaration-
part of a blo ck shall constitute its de ning-p oint as a variable-identi er for the region that is
the blo ck. The structure of a variable p ossessing a structured-typ e shall be the structure of the
structured-typ e. A use of a variable-access shall b e an access, at the time of the use, to the variable
thereby denoted. A variable-access, according to whether it is an entire-variable, a comp onent-
variable, an identi ed-variable, or a bu er-variable, shall denote a declared variable, a comp onentof
avariable, a variable that is identi ed byapointer value (see 6.4.4), or a bu er-variable, resp ectively.
variable-access = entire-variable j comp onent-variable j identi ed-variable
j bu er-variable .
Example of a variable-declaration-part:
var
x, y, z, max : real;
i, j : integer;
k : 0..9;
p, q, r : Boolean;
operator : (plus, minus, times);
a : array [0..63] of real;
c : colour;
f : file of char;
hue1, hue2 : set of colour;
p1, p2 : person; 26
ISO/IEC 7185:1990(E)
m, m1, m2 : array [1..10, 1..10] of real;
coord : polar;
pooltape : array [1..4] of FileOfInteger;
date : record
month : 1..12;
year : integer
end;
NOTE | Variables o ccurring in examples in the remainder of this International Standard should b e assumed
to have b een declared as sp eci ed in the ab ove example.
6.5.2 Entire-variables
entire-variable = variable-identi er .
variable-identi er = identi er .
6.5.3 Comp onent-variables
6.5.3.1 General
A comp onentofavariable shall b e a variable. A comp onent-variable shall denote a comp onentof
avariable. A reference or an access to a comp onentofavariable shall constitute a reference or an
access, resp ectively,tothevariable. The value, if any, of the comp onentofavariable shall b e the
same comp onentofthevalue, if any,ofthevariable.
comp onent-variable = indexed-variable j eld-designator .
6.5.3.2 Indexed-variables
Acomponentofavariable p ossessing an array-typ e shall b e denoted by an indexed-variable.
indexed-variable = array-variable `[' index-expression, f `,' index-expression g `]' .
array-variable = variable-access .
index-expression = expression .
An array-variable shall b e a variable-access that denotes a variable p ossessing an array-typ e. For an
indexed-variable closest-containing a single index-expression, the value of the index-expression shall
be assignment-compatible with the index-typ e of the array-typ e. The comp onent denoted by the
indexed-variable shall b e the comp onent that corresp onds to the value of the index-expression by
the mapping of the typ e p ossessed by the array-variable (see 6.4.3.2).
Example 1:
a[12]
a[i + j] 27
ISO/IEC 7185:1990(E)
m[k]
If the array-variable is itself an indexed-variable, an abbreviation shall be p ermitted. In the
abbreviated form, a single comma shall replace the sequence ] [ that o ccurs in the full form. The
abbreviated form and the full form shall b e equivalent.
The order of b oth the evaluation of the index-expressions of, and the access to the array-variable of,
an indexed-variable shall b e implementation-dep endent.
Example 2:
m[k][1]
m[k, 1]
NOTE | These two examples denote the same comp onent-variable.
6.5.3.3 Field-designators
A eld-designator either shall denote that comp onent of the record-variable of the eld-designator
asso ciated (see 6.4.3.3) with the eld-identi er of the eld-sp eci er of the eld-designator or shall
denote the variable denoted by the eld-designator-identi er (see 6.8.3.10) of the eld-designator.
A record-variable shall b e a variable-access that denotes a variable p ossessing a record-typ e.
The o ccurrence of a record-variable in a eld-designator shall constitute the de ning-p oint of the
eld-identi ers asso ciated with comp onents of the record-typ e p ossessed by the record-variable, for
the region that is the eld-sp eci er of the eld-designator.
eld-designator = record-variable `.' eld-sp eci er j eld-designator-identi er .
record-variable = variable-access .
eld-sp eci er = eld-identi er .
Examples:
p2".mother
coord.theta
An access to a comp onent ofavariantofa variant-part, where the selector of the variant-part is not
a eld, shall attribute to the selector that value asso ciated (see 6.4.3.3) with the variant. It shall
b e an error unless a variant is active for the entiretyofeach reference and access to eachcomponent
of the variant.
When a variant b ecomes non-active, all of its comp onents shall b ecome totally-unde ned.
NOTE | If the selector of a variant-part is unde ned, then no variant of the variant-part is active.
6.5.4 Identi ed-variables
An identi ed-variable shall denote the variable, if any, identi ed by the value of the p ointer-variable
of the identi ed-variable (see 6.4.4 and 6.6.5.3) shall be accessible until the termination of the
activation of the program-blo ckoruntil the variable is made inaccessible (see the required pro cedure 28
ISO/IEC 7185:1990(E)
disp ose, 6.6.5.3).
NOTE | The accessibility of the variable also dep ends on the existence of a pointer-variable that has
attributed to it the corresp onding identifying-value.
Apointer-variable shall b e a variable-access that denotes a variable p ossessing a p ointer-typ e. It shall
b e an error if the p ointer-variable of an identi ed-variable either denotes a nil-value or is unde ned.
It shall b e an error to remove from the set of values of the p ointer-typ e the identifying-value of an
identi ed-variable (see 6.6.5.3) when a reference to the identi ed-variable exists.
Examples:
p1"
p1".father"
p1".sibling".father"
6.5.5 Bu er-variables
A le-variable shall be a variable-access that denotes a variable p ossessing a le-typ e. A bu er-
variable shall denote a variable asso ciated with the variable denoted by the le-variable of the
bu er-variable. A bu er-variable asso ciated with a text le shall p ossess the char-typ e; otherwise, a
bu er-variable shall p ossess the comp onent-typ e of the le-typ e p ossessed by the le-variable of the
bu er-variable.
bu er-variable = le-variable `"' .
le-variable = variable-access .
Examples:
input"
pooltape[2]"
It shall be an error to alter the value of a le-variable f when a reference to the bu er-variable
f" exists. A reference or an access to a bu er-variable shall constitute a reference or an access,
resp ectively, to the asso ciated le-variable.
6.6 Pro cedure and function declarations
6.6.1 Pro cedure-declarations
pro cedure-declaration = pro cedure-heading `;' directive
j pro cedure-identi cation `;' pro cedure-blo ck
j pro cedure-heading `;' pro cedure-blo ck .
pro cedure-heading = `pro cedure'identi er [ formal-parameter-list ] .
pro cedure-identi cation = `pro cedure' pro cedure-identi er .
pro cedure-identi er = identi er .
pro cedure-blo ck = blo ck . 29
ISO/IEC 7185:1990(E)
The o ccurrence of a formal-parameter-list in a pro cedure-heading of a pro cedure-declaration shall
de ne the formal-parameters of the pro cedure-blo ck, if any, asso ciated with the identi er of the
pro cedure-heading to b e those of the formal-parameter-list.
The o ccurrence of an identi er in the pro cedure-heading of a pro cedure-declaration shall constitute
its de ning-p oint as a pro cedure-identi er for the region that is the blo ck closest-containing the
pro cedure-declaration.
Each identi er having a de ning-p oint as a pro cedure-identi er in a pro cedure-heading of a pro cedure-
declaration in which the directive forward o ccurs shall have exactly one of its applied o ccurrences
in a pro cedure-identi cation of a pro cedure-declaration, and this applied o ccurrence shall b e closest-
contained by the pro cedure-and-function-declaration-part closest-containing the pro cedure-heading.
The o ccurrence of a pro cedure-blo ck in a pro cedure-declaration shall asso ciate the pro cedure-blo ck
with the identi er in the pro cedure-heading, or with the pro cedure-identi er in the pro cedure-
identi cation, of the pro cedure-declaration.
There shall b e at most one pro cedure-blo ck asso ciated with a pro cedure-identi er.
Examples of procedure-and-function-declaration-parts:
Example 1:
NOTE --- This example is not for level 0.
procedure AddVectors (var A, B, C : array [low..high : natural] of real);
var
i : natural;
begin
for i := low to high do A[i] := B[i] + C[i]
end f of AddVectors g;
Example 2:
procedure readinteger (var f : text; var x : integer);
var
i : natural;
begin
while f" = ' ' do get(f);
fThe buffer-variable contains the first non-space charg
i := 0;
while f" in ['0'..'9'] do begin
i := (10 * i) + (ord(f") - ord('0'));
get(f)
end;
fThe buffer-variable contains a non-digitg
x := i
fOf course if there are no digits, x is zerog 30
ISO/IEC 7185:1990(E)
end;
procedure bisect (function f(x : real) : real;
a, b : real;
var result : real);
fThis procedure attempts to find a zero of f(x) in (a,b) by
the method of bisection. It is assumed that the procedure is
called with suitable values of a and b such that
(f(a) < 0) and (f(b) >= 0)
The estimate is returned in the last parameter.g
const
eps = 1e-10;
var
midpoint : real;
begin
fThe invariant P is true by calling assumptiong
midpoint := a;
while abs(a - b) > eps * abs(a) do begin
midpoint := (a + b) / 2;
if f(midpoint) < 0 then a := midpoint
else b := midpoint
fWhich re-establishes the invariant:
P = (f(a) < 0) and (f(b) >= 0)
and reduces the interval (a,b) provided that the
value of midpoint is distinct from both a and b.g
end;
fP together with the loop exit condition assures that a zero
is contained in a small subinterval. Return the midpoint as
the zero.g
result := midpoint
end;
procedure PrepareForAppending (var f : FileOfInteger);
f This procedure takes a file in any state suitable for reset and
places it in a condition for appending data to its end. Simpler
conditioning is only possible if assumptions are made about the
initial state of the file. g
var
LocalCopy : FileOfInteger;
procedure CopyFiles (var from, into : FileOfInteger);
begin
reset(from); rewrite(into);
while not eof(from) do begin
into" := from";
put(into); get(from) 31
ISO/IEC 7185:1990(E)
end
end f of CopyFiles g;
begin f of body of PrepareForAppending g
CopyFiles(f, LocalCopy);
CopyFiles(LocalCopy, f)
end f of PrepareForAppending g;
6.6.2 Function-declarations
function-declaration = function-heading `;' directive
j function-identi cation `;' function-blo ck
j function-heading `;' function-blo ck .
function-heading = `function' identi er [ formal-parameter-list ]`:' result-typ e .
function-identi cation = `function' function-identi er .
function-identi er = identi er .
result-typ e = simple-typ e-identi er j pointer-typ e-identi er .
function-blo ck = blo ck .
The o ccurrence of a formal-parameter-list in a function-heading of a function-declaration shall de ne
the formal-parameters of the function-blo ck, if any, asso ciated with the identi er of the function-
heading to be those of the formal-parameter-list. The function-blo ck shall contain at least one
assignment-statement such that the function-identi er of the assignment-statement is asso ciated
with the blo ck (see 6.8.2.2).
The o ccurrence of an identi er in the function-heading of a function-declaration shall constitute its
de ning-p oint as a function-identi er asso ciated with the result typ e denoted by the result-typ e for
the region that is the blo ck closest-containing the function-declaration.
Eachidenti er having a de ning-p oint as a function-identi er in the function-heading of a function-
declaration in which the directive forward o ccurs shall have exactly one of its applied o ccurrences
in a function-identi cation of a function-declaration, and this applied o ccurrence shall be closest-
contained by the pro cedure-and-function-declaration-part closest-containing the function-heading.
The o ccurrence of a function-blo ck in a function-declaration shall asso ciate the function-blo ck with
the identi er in the function-heading, or with the function-identi er in the function-identi cation,
of the function-declaration; the blo ck of the function-blo ck shall b e asso ciated with the result typ e
that is asso ciated with the identi er or function-identi er.
There shall b e at most one function-blo ck asso ciated with a function-identi er.
Example of a procedure-and-function-declaration-part:
function Sqrt (x : real) : real;
fThis function computes the square root of x (x > 0) using Newton's
method.g 32
ISO/IEC 7185:1990(E)
var
old, estimate : real;
begin
estimate := x;
repeat
old := estimate;
estimate := (old + x / old) * 0.5;
until abs(estimate - old) < eps * estimate;
feps being a global constantg
Sqrt := estimate
end f of Sqrt g;
function max (a : vector) : real;
fThis function finds the largest component of the value of a.g
var
largestsofar : real;
fence : indextype;
begin
largestsofar := a[1];
fEstablishes largestsofar = max(a[1])g
for fence := 2 to limit do begin
if largestsofar < a[fence] then largestsofar := a[fence]
fRe-establishing largestsofar = max(a[1], ... ,a[fence])g
end;
fSo now largestsofar = max(a[1], ... ,a[limit])g
max := largestsofar
end f of max g;
function GCD (m, n : natural) : natural;
begin
if n=0 then GCD := m else GCD := GCD(n, m mod n);
end;
fThe following two functions analyze a parenthesized expression and
convert it to an internal form. They are declared forward
since they are mutually recursive, i.e., they call each other.
These function-declarations use the following identifiers that are not
defined in this International Standard: formula, IsOpenParenthesis, IsOperator,
MakeFormula, nextsym, operation, ReadElement, ReadOperator, and
SkipSymbol. g
function ReadExpression : formula; forward;
function ReadOperand : formula; forward; 33
ISO/IEC 7185:1990(E)
function ReadExpression; fSee forward declaration of heading.g
var
this : formula;
op : operation;
begin
this := ReadOperand;
while IsOperator(nextsym) do
begin
op := ReadOperator;
this := MakeFormula(this, op, ReadOperand);
end;
ReadExpression := this
end;
function ReadOperand; fSee forward declaration of heading.g
begin
if IsOpenParenthesis(nextsym) then
begin
SkipSymbol;
ReadOperand := ReadExpression;
fnextsym should be a close-parenthesisg
SkipSymbol
end
else ReadOperand := ReadElement
end;
6.6.3 Parameters
6.6.3.1 General
The identi er-list in avalue-parameter-sp eci cation shall b e a list of value parameters. The identi er-
list in avariable-parameter-sp eci cation shall b e a list of variable parameters.
formal-parameter-list = `(' formal-parameter-section f `;' formal-parameter-section g `)' .
formal-parameter-section > value-parameter-sp eci cation
j variable-parameter-sp eci cation
j pro cedural-parameter-sp eci cation
j functional-parameter-sp eci cation .
NOTE | 1 There is also a syntax rule for formal-parameter-section in 6.6.3.7.1.
value-parameter-sp eci cation = identi er-list `:' typ e-identi er .
variable-parameter-sp eci cation = `var'identi er-list `:' typ e-identi er . 34
ISO/IEC 7185:1990(E)
pro cedural-parameter-sp eci cation = pro cedure-heading .
functional-parameter-sp eci cation = function-heading .
An identi er de ned to b e a parameter-identi er for the region that is the formal-parameter-list of
a pro cedure-heading shall b e designated a formal-parameter of the blo ck of the pro cedure-blo ck, if
any, asso ciated with the identi er of the pro cedure-heading. An identi er de ned to b e a parameter-
identi er for the region that is the formal-parameter-list of a function-heading shall b e designated
a formal-parameter of the blo ck of the function-blo ck, if any, asso ciated with the identi er of the
function-heading.
The o ccurrence of an identi er in the identi er-list of avalue-parameter-sp eci cation or a variable-
parameter-sp eci cation shall constitute its de ning-p oint as a parameter-identi er for the region that
is the formal-parameter-list closest-containing it, and its de ning-p oint as the asso ciated variable-
identi er for the region that is the blo ck, if any,ofwhich it is a formal-parameter.
The o ccurrence of the identi er of a pro cedure-heading in a pro cedural-parameter-sp eci cation shall
constitute its de ning-p oint as a parameter-identi er for the region that is the formal-parameter-list
closest-containing it, and its de ning-p oint as the asso ciated pro cedure-identi er for the region that
is the blo ck, if any,ofwhich it is a formal-parameter.
The o ccurrence of the identi er of a function-heading in a functional-parameter-sp eci cation shall
constitute its de ning-p oint as a parameter-identi er for the region that is the formal-parameter-list
closest-containing it, and its de ning-p oint as the asso ciated function-identi er for the region that is
the blo ck, if any, of which it is a formal-parameter.
NOTE | 2 If the formal-parameter-list is contained in a pro cedural-parameter-sp eci cation or a functional-
parameter-sp eci cation, there is no corresp onding pro cedure-blo ck or function-blo ck.
6.6.3.2 Value parameters
The formal-parameter and its asso ciated variable-identi er shall denote the same variable. The
formal-parameter shall p ossess the typ e denoted by the typ e-identi er of the value-parameter-
sp eci cation. The typ e p ossessed by the formal-parameter shall be one that is p ermitted as the
comp onent-typ e of a le-typ e (see 6.4.3.5). The actual-parameter (see 6.7.3 and 6.8.2.3) shall b e
an expression whose value is assignment-compatible with the typ e p ossessed by the formal-parameter.
The currentvalue of the expression shall b e attributed up on activation of the blo ck to the variable
that is denoted by the formal-parameter.
6.6.3.3 Variable parameters
The actual-parameter shall b e a variable-access. The typ e p ossessed by the actual-parameters shall
b e the same as that denoted bythetyp e-identi er of the variable-parameter-sp eci cation, and the
formal-parameters shall also p ossess that typ e. The actual-parameter shall b e accessed b efore the
activation of the blo ck, and this access shall establish a reference to the variable thereby accessed
during the entire activation of the blo ck; the corresp onding formal-parameter and its asso ciated
variable-identi er shall denote the referenced variable during the activation. 35
ISO/IEC 7185:1990(E)
An actual variable parameter shall not denote a eld that is the selector of a variant-part. An actual
variable parameter shall not denote a comp onentofavariable where that variable p ossesses a typ e
that is designated packed.
6.6.3.4 Pro cedural parameters
The actual-parameter (see 6.7.3 and 6.8.2.3)shall be a pro cedure-identi er that has a de ning-
point contained by the program-blo ck. The formal-parameter-list, if any, closest-contained by the
formal-parameter-section and the formal-parameter-list, if any, that de nes the formal-parameters of
the pro cedure denoted by the actual-parameter shall b e congruous, or neither formal-parameter-list
shall o ccur. The formal-parameter and its asso ciated pro cedure-identi er shall denote the actual-
parameter during the entire activation of the blo ck.
6.6.3.5 Functional parameters
The actual-parameter (see 6.7.3 and 6.8.2.3) shall b e a function-identi er that has a de ning-p oint
contained by the program-blo ck. The formal-parameter-list, if any, closest-contained by the formal-
parameter-section and the formal-parameter-list, if any, that de nes the formal-parameters of the
function denoted by the actual-parameter shall b e congruous, or neither formal-parameter-list shall
occur. The result-typ e closest-contained by the formal-parameter-section shall denote the same typ e
as the result typ e of the function. The formal-parameter and its asso ciated function-identi er shall
denote the actual-parameter during the entire activation of the blo ck.
6.6.3.6 Parameter list congruity
Two formal-parameter-lists shall b e congruous if they contain the same numb er of formal-parameter-
sections and if the formal-parameter-sections in corresp onding p ositions match. Two formal-
parameter-sections shall matchifany of the following statements is true.
a) They are b oth value-parameter-sp eci cations containing the same numb er of parameters and
the typ e-identi er in eachvalue-parameter-sp eci cation denotes the same typ e.
b) They are both variable-parameter-sp eci cations containing the same number of parameters
and the typ e-identi er in eachvariable-parameter-sp eci cation denotes the same typ e.
c) They are both pro cedural-parameter-sp eci cations and the formal-parameter-lists of the
pro cedure-headings thereof are congruous.
d) They are b oth functional-parameter-sp eci cations, the formal-parameter-lists of the function-
headings thereof are congruous, and the typ e-identi ers of the result-typ es of the function-
headings thereof denote the same typ e.
e) They are either b oth value-conformant-array-sp eci cations or b oth variable-conformant-array-
sp eci cations; and in both cases the conformant-array-parameter-sp eci cations contain the
same numb er of parameters and equivalent conformant-array-schemas. Two conformant-array-
schemas shall b e equivalent if all of the following four statements are true.
1) There is a single index-typ e-sp eci cation in each conformant-array-schema. 36
ISO/IEC 7185:1990(E)
2) The ordinal-typ e-identi er in each index-typ e-sp eci cation denotes the same typ e.
3) Either the (comp onent) conformant-array-schemas of the conformant-array-schemas are
equivalentorthetyp e-identi ers of the conformant-array-schemas denote the same typ e.
4) Either b oth conformant-array-schemas are packed-conformant-array-schemas or b oth are
unpacked-conformant-array-schemas.
NOTES
1 The abbreviated conformant-array-schema and its corresp onding full form are equivalent (see 6.6.3.7).
2For the status of item e) ab ovesee5.1 a), 5.1 b), 5.1 c), 5.2 a), and 5.2 b).
6.6.3.7 Conformantarray parameters
NOTE | For the status of this sub clause see 5.1 a), 5.1 b), 5.1 c), 5.2 a), and 5.2 b).
6.6.3.7.1 General
The o ccurrence of an identi er in the identi er-list contained by a conformant-array-parameter-
sp eci cation shall constitute its de ning-p oint as a parameter-identi er for the region that is the
formal-parameter-list closest-containing it and its de ning-p oint as the asso ciated variable-identi er
for the region that is the blo ck, if any, of whichit is a formal-parameter. A variable-identi er so
de ned shall b e designated a conformant-array-parameter.
The o ccurrence of an identi er in an index-typ e-sp eci cation shall constitute its de ning-p oint as
a b ound-identi er for the region that is the formal-parameter-list closest-containing it and for the
region that is the blo ck, if any, whose formal-parameters are sp eci ed by that formal-parameter-list.
formal-parameter-section > conformant-array-parameter-sp eci cation .
conformant-array-parameter-sp eci cation = value-conformant-array-sp eci cation
j variable-conformant-array-sp eci cation .
value-conformant-array-sp eci cation = identi er-list `:' conformant-array-schema .
variable-conformant-array-sp eci cation = `var'identi er-list `:' conformant-array-schema .
conformant-array-schema = packed-conformant-array-schema
j unpacked-conformant-array-schema .
packed-conformant-array-schema = `packed'`array'`[' index-typ e-sp eci cation `]'
`of'typ e-identi er .
unpacked-conformant-array-schema =
`array'`[' index-typ e-sp eci cation f `;' index-typ e-sp eci cation g `]'
`of'( typ e-identi er j conformant-array-schema ) .
index-typ e-sp eci cation = identi er `..' identi er `:' ordinal-typ e-identi er .
factor > b ound-identi er . 37
ISO/IEC 7185:1990(E)
b ound-identi er = identi er .
NOTE | 1 There are also syntax rules for formal-parameter-section in 6.6.3.1 and for factor in 6.7.1.
If a conformant-array-schema closest-contains a conformant-array-schema, then an abbreviated form
of de nition shall b e p ermitted. In the abbreviated form, a single semicolon shall replace the sequence
]ofarray [ that o ccurs in the full form. The abbreviated form and the full form shall b e equivalent.
Examples:
array [u..v : T1] of array [j..k : T2] of T3
array [u..v : T1; j..k : T2] of T3
Within the activation of the blo ck, applied o ccurrences of the rst identi er of an index-typ e-
sp eci cation shall denote the smallest value sp eci ed by the corresp onding index-typ e (see 6.6.3.8)
p ossessed by the actual-parameter, and applied o ccurrences of the second identi er of the index-
typ e-sp eci cation shall denote the largest value sp eci ed by that index-typ e.
NOTE | 2 The ob ject denoted by a b ound-identi er is neither a constantnoravariable.
The actual-parameters (see 6.7.3 and 6.8.2.3) corresp onding to formal-parameters that o ccur in a
single conformant-array-parameter-sp eci cation shall all p ossess the same typ e. The typ e p ossessed
by the actual-parameters shall be conformable (see 6.6.3.8) with the conformant-array-schema,
and the formal-parameters shall p ossess an array-typ e which shall b e distinct from any other typ e
and which shall have a comp onent-typ e that shall b e the xed-comp onent-typ e of the conformant-
array-parameters de ned in the conformant-array-parameter-sp eci cation and that shall have the
index-typ es of the typ e p ossessed by the actual-parameters that corresp ond (see 6.6.3.8) to the
index-typ e-sp eci cations contained by the conformant-array-schema contained by the conformant-
array-parameter-sp eci cation. The typ e denoted bythetyp e-identi er contained by the conformant-
array-schema contained by a conformant-array-parameter-sp eci cation shall b e designated the xed-
component-type of the conformant-array-parameters de ned by that conformant-array-parameter-
sp eci cation.
NOTE | 3 The typ e p ossessed by the formal-parameter cannot b e a string-typ e (see 6.4.3.2) b ecause it is
not denoted byanarray-typ e.
6.6.3.7.2 Value conformant arrays
The identi er-list in avalue-conformant-array-sp eci cation shall b e a list of value conformant arrays.
Each actual-parameter corresp onding to a value formal-parameter shall b e an expression. The value
of the expression shall b e attributed b efore activation of the blo cktoanauxiliaryvariable that the
program do es not otherwise contain. The typ e p ossessed bythisvariable shall b e the same as that
possessed by the expression. This variable shall b e accessed b efore the activation of the blo ck, and
this access shall establish a reference to the variable thereby accessed during the entire activation of
the blo ck; the corresp onding formal-parameter and its asso ciated variable-identi er shall represent
the referenced variable during the activation. The xed-comp onent-typ e of a value conformantarray
shall b e one that is p ermitted as the comp onent-typ e of a le-typ e. 38
ISO/IEC 7185:1990(E)
If the actual-parameter contains an o ccurrence of a conformant-array-parameter, then for each
o ccurrence of the conformant-array-parameter contained by the actual-parameter, either
a) the o ccurrence of the conformant-array-parameter shall b e contained by a function-designator
contained by the actual-parameter; or
b) the o ccurrence of the conformant-array-parameter shall be contained byan indexed-variable
contained by the actual-parameter, such that the typ e p ossessed by that indexed-variable is
the xed-comp onent-typ e of the conformant-array-parameter.
NOTE | This ensures that the typ e p ossessed by the expression and the auxiliary variable will always b e
known and that, as a consequence, the activation record of a pro cedure can b e of a xed size.
6.6.3.7.3 Variable conformant arrays
The identi er-list in avariable-conformant-array-sp eci cation shall b e a list of variable conformant
arrays. The actual-parameter shall be a variable-access. The actual-parameter shall be accessed
b efore the activation of the blo ck, and this access shall establish a reference to the variable thereby
accessed during the entire activation of the blo ck; the corresp onding formal-parameter and its
asso ciated variable-identi er shall denote the referenced variable during the activation.
An actual-parameter shall not denote a comp onentofavariable where that variable p ossesses a typ e
that is designated packed.
6.6.3.8 Conformability
NOTE | 1 For the status of this sub clause see 5.1 a), 5.1 b), 5.1 c), 5.2 a),and5.2 b).
Given a typ e denoted by an array-typ e closest-containing a single index-typ e and a conformant-
array-schema closest-containing a single index-typ e-sp eci cation, then the index-typ e and the index-
typ e-sp eci cation shall b e designated as corresponding. Given two conformant-array-schemas closest-
containing a single index-typ e-sp eci cation, then the two index-typ e-sp eci cations shall b e designated
as corresp onding. Let T1 b e an array-typ e with a single index-typ e and let T2 b e the typ e denoted
by the ordinal-typ e-identi er of the index-typ e-sp eci cation of a conformant-array-schema closest-
containing a single index-typ e-sp eci cation; then T1 shall b e conformable with the conformant-array-
schema if all the following four statements are true.
a) The index-typ e of T1 is compatible with T2.
b) The smallest and largest values sp eci ed by the index-typ e of T1 lie within the closed interval
sp eci ed byT2.
c) The comp onent-typ e of T1 denotes the same typ e as that denoted bythetyp e-identi er of the
conformant-array-schema or is conformable to the conformant-array-schema in the conformant-
array-schema.
d) Either T1 is not designated packed and the conformant-array-schema is an unpacked-conformant-
array-schema, or T1 is designated packed and the conformant-array-schema is a packed-
conformant-array-schema. 39
ISO/IEC 7185:1990(E)
NOTE | 2 The abbreviated and full forms of a conformant-array-schema are equivalent(see 6.6.3.7). The
abbreviated and full forms of an array-typ e are equivalent(see 6.4.3.2).
Atany place where the rule of conformability is used, it shall b e an error if the smallest or largest
value sp eci ed by the index-typ e of T1 lies outside the closed interval sp eci ed by T2.
6.6.4 Required pro cedures and functions
The required pro cedure-identi ers and function-identi ers and the corresp onding required pro cedures
and functions shall b e as sp eci ed in 6.6.5, 6.6.6,and 6.9.
NOTE | Required pro cedures and functions do not necessarily follow the rules given elsewhere for pro cedures
and functions.
6.6.5 Required pro cedures
6.6.5.1 General
The required pro cedures shall be le handling pro cedures, dynamic allo cation pro cedures and
transfer pro cedures.
6.6.5.2 File handling pro cedures
Except for the application of rewrite or reset to the program parameters denoted by input or
output, the e ects of applying each of the le handling pro cedures rewrite, put, reset,andget
to a le-variable f shall b e de ned by pre-assertions and p ost-assertions ab out f, its comp onents f.L,
f.R, and f.M, and the asso ciated bu er-variable f". The use of the variable f0 within an assertion
shall b e considered to represent the state or value, as appropriate, of f prior to the op eration, while
f (within an assertion) shall denote the variable after the op eration, and similarly for f0" and f".
It shall be an error if the stated pre-assertion do es not hold immediately prior to any use of the
de ned op eration. It shall b e an error if anyvariable explicitly denoted in an assertion of equality
is unde ned. The p ost-assertion shall hold prior to the next subsequent access to the le, its
comp onents, or its asso ciated bu er-variable. The p ost-assertions imply corresp onding activities on
the external entities, if any, to which the le-variables are b ound. These activities, and the p ointat
which they are actually p erformed, shall b e implementation-de ned.
NOTE | In order to facilitate interactive terminal input and output, the pro cedure get (and other input
pro cedures) should be p erformed at the latest opp ortunity, and the pro cedure put (and other output
pro cedures) should b e p erformed at the rst opp ortunity. This technique has b een called `lazy I/O'.
rewrite(f )
pre-assertion: true.
p ost-assertion: (f.L = f.R = S( )) and (f.M = Generation) and
(f" is totally-unde ned).
put(f )
pre-assertion: (f0.M = Generation) and (f0.L is not unde ned) and (f0.R = S( )) and 40
ISO/IEC 7185:1990(E)
(f0" is not unde ned).
p ost-assertion: (f.M = Generation) and (f.L = (f0.L ~S(f0")) ) and (f.R = S( )) and
(f" is totally-unde ned).
reset(f )
pre-assertion: The comp onents f0.L and f0.R are not unde ned.
p ost-assertion: (f.L = S( )) and (f.R = (f0.L ~f0.R ~X)) and
(f.M = Insp ection) and
(if f.R = S( ) then (f" is totally-unde ned) else (f" = f.R. rst)),
where, if f p ossesses the typ e denoted by the required typ e-identi er text and if f0.L ~f0.R is
not empty and if (f0.L ~f0.R).last is not an end-of-line, then X shall b e a sequence having an
end-of-line comp onent as its only comp onent; otherwise, X = S( ).
get(f )
pre-assertion: (f0.M = Insp ection) and (neither f0.L nor f0.R is unde ned) and
(f0.R <> S( )).
p ost-assertion: (f.M = Insp ection) and (f.L = (f0.L ~ S(f0.R. rst))) and (f.R = f0.R.rest) and
(if f.R = S( )
then (f" is totally-unde ned)
else (f" = f.R. rst)).
When the le-variable f p ossesses a typ e other than that denoted by text, the required pro cedures
read and write shall b e de ned as follows.
read
Let f denote a le-variable and v ,...,v denote variable-accesses (n>=2); then the pro cedure-
1 n
statement read(f,v ,...,v ) shall access the le-variable and establish a reference to that le-
1 n
variable for the remaining execution of the statement. The execution of the statement shall
b e equivalentto
b egin read( ,v ); read( ,v ,...,v )end
1 2 n
where denotes the referenced le-variable.
Let f b e a le-variable and v b e a variable-access; then the pro cedure-statement read(f,v) shall
access the le-variable and establish a reference to that le-variable for the remaining execution
of the statement. The execution of the statement shall b e equivalentto
b egin v := "; get( ) end
where denotes the referenced le-variable.
NOTE | The variable-access is not a variable parameter. Consequently,itmay b e a comp onentofa
packed structure, and the value of the bu er-variable need only b e assignment-compatible with it.
write
Let f denote a le-variable and e ,...,e denote expressions (n>=2); then the pro cedure-
1 n
statement write(f,e ,...,e ) shall access the le-variable and establish a reference to that le-
1 n 41
ISO/IEC 7185:1990(E)
variable for the remaining execution of the statement. The execution of the statement shall
b e equivalentto
b egin write( ,e ); write( ,e ,...,e ) end
1 2 n
where denotes the referenced le-variable.
Let f b e a le-variable and e b e an expression; then the pro cedure-statement write(f,e) shall
access the le-variable and establish a reference to that le-variable for the remaining execution
of the statement. The execution of the write statement shall b e equivalentto
begin " := e; put( ) end
where denotes the referenced le-variable.
NOTES
1 The required pro cedures read, write, readln, writeln, and page, as applied to text les, are
describ ed in 6.10.
2 Since the de nitions of read and write include the use of get and put, the implementation-de ned
asp ects of their p ost-assertions also apply.
3 A consequence of the de nition of read and write is that the non- le parameters are evaluated in
a left-to-right order.
6.6.5.3 Dynamic allo cation pro cedures
new(p)
shall create a new variable that is totally-unde ned, shall create a new identifying-value of
the pointer-typ e asso ciated with p, that identi es the new variable, and shall attribute this
identifying-value to the variable denoted by the variable-access p. The created variable shall
p ossess the typ e that is the domain-typ e of the p ointer-typ e p ossessed byp.
new(p,c ,...,c )
1 n
shall create a new variable that is totally-unde ned, shall create a new identifying-value of
the pointer-typ e asso ciated with p, that identi es the new variable, and shall attribute this
identifying-value to the variable denoted by the variable-access p. The created variable shall
p ossess the record-typ e that is the domain-typ e of the p ointer-typ e p ossessed by p and shall
have nested variants that corresp ond to the case-constants c ,...,c . The case-constants shall
1 n
b e listed in order of increasing nesting of the variant-parts. Anyvariant not sp eci ed shall b e
at a deep er level of nesting than that sp eci ed bycn.
It shall b e an error if a variantofavariant-part within the new variable is active and a di erent
variant of the variant-part is one of the sp eci ed variants.
dispose(q)
shall remove the identifying-value denoted by the expression q from the p ointer-typ e of q. It
shall b e an error if the identifying-value had b een created using the form new(p,c ,...,c ).
1 n
dispose(q,k ,...,k )
1 m
shall remove the identifying-value denoted by the expression q from the p ointer-typ e of q. The 42
ISO/IEC 7185:1990(E)
case-constants k ,...,k shall be listed in order of increasing nesting of the variant-parts. It
1 m
shall b e an error unless the variable had b een created using the form new(p,c ,...,c )andmis
1 n
equal to n. It shall b e an error if the variants in the variable identi ed by the p ointer value of
q are di erent from those sp eci ed by the values denoted by the case-constants k ,...,k .
1 m
NOTE | The removal of an identifying-value from the p ointer-typ e to which it b elongs renders the identi ed-
variable inaccessible (see 6.5.4) and makes unde ned all variables and functions that have that value
attributed (see 6.6.3.2 and 6.8.2.2).
It shall b e an error if q has a nil-value or is unde ned.
It shall b e an error if a variable created using the second form of new is accessed by the identi ed-
variable of the variable-access of a factor, of an assignment-statement, or of an actual-parameter.
6.6.5.4 Transfer pro cedures
In the statement pack(a,i,z) and in the statement unpack(z,a,i) the following shall hold: a and z
shall be variable-accesses; a shall p ossess an array-typ e not designated packed; z shall p ossess an
array-typ e designated packed; the comp onent-typ es of the typ es of a and z shall b e the same; and
the value of the expression i shall b e assignment-compatible with the index-typ e of the typ e of a.
Let j and k denote auxiliary variables that the program do es not otherwise contain and that have the
typ e that is the index-typ e of the typ e of z and a, resp ectively. Let u and v denote the smallest and
largest values of the index-typ e of the typ e of z. Each of the statements pack(a,i,z) and unpack(z,a,i)
shall establish references to the variables denoted by a and z for the remaining execution of the
statements; let aa and zz, resp ectively, denote the referenced variables within the following sentence.
Then the statement pack(a,i,z) shall b e equivalentto
b egin
k:=i;
for j := u to v do
b egin
zz[j] := aa[k];
if j <> v then k := succ(k)
end
end
and the statement unpack(z,a,i) shall b e equivalentto
b egin
k:=i;
for j := u to v do
b egin
aa[k] := zz[j];
if j <> v then k := succ(k)
end
end
NOTE | Errors will arise if the references cannot b e established, if one or more of the values attributed to 43
ISO/IEC 7185:1990(E)
j is not assignment-compatible with the index-typ e of the typeofa,orifanevaluated array comp onentis
unde ned.
6.6.6 Required functions
6.6.6.1 General
The required functions shall be arithmetic functions, transfer functions, ordinal functions, and
Bo olean functions.
6.6.6.2 Arithmetic functions
For the following arithmetic functions, the expression x shall b e either of real-typ e or integer-typ e.
For the functions abs and sqr,thetyp e of the result shall b e the same as the typ e of the parameter,
x. For the remaining arithmetic functions, the result shall always b e of real-typ e. The result shall
be as shown in table 2.
Table 2 | Arithmetic function results
Function Result
abs(x) absolute value of x
sqr(x) square of x
It shall b e an error if suchavalue do es not exist.
sin(x) sine of x, where x is in radians
cos(x) cosine of x, where x is in radians
exp(x) base of natural logarithms raised to the p ower x
ln(x) natural logarithm of x, if x is greater than zero
It shall b e an error if x is not greater than zero.
sqrt(x) non-negative square ro ot of x, if x is not negative
It shall b e an error if x is negative.
arctan(x) principal value, in radians, of the arctangentofx
6.6.6.3 Transfer functions
trunc(x)
From the expression x that shall b e of real-typ e, this function shall return a result of integer-
typ e. The value of trunc(x) shall b e suchthatifxispositive or zero, then 0x trunc(x)<1;
otherwise, 1