28.06.2013 Views

ISO Pascal reference manual

ISO Pascal reference manual

ISO Pascal reference manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

PROGRAM fail(output);<br />

PROCEDURE try(FUNCTION x(n : integer):integer); BEGIN<br />

writeln(x(123));<br />

END;<br />

BEGIN<br />

try(PRED); (wrong}<br />

try(SQR); (wrong}<br />

END.<br />

*ERROR 133 -- this function cannot execute an assignment<br />

of the form: := result<br />

All functions must contain at least one executable statement of the form:<br />

functionid := expression;<br />

in order that the result of the function shall be defined. The error message<br />

indicates that either no such statement occurred at all, or that it is known to<br />

the compiler that none can ever be executed.<br />

PROGRAM fail;<br />

CONST flag = 1;<br />

VAR x : integer;<br />

FUNCTION one:integer<br />

BEGIN<br />

IF flag = 0 THEN one := 1; [can never be executed}<br />

END;<br />

BEGIN<br />

x := one;<br />

END.<br />

*ERROR 134 -- the assignment of a value to may occur only<br />

within the definition of the function <br />

The result of a function is assigned by a special form of the assignment<br />

statement in which the name of the function appears on the left-hand side,<br />

This form of assignment is only permitted within the definition of the<br />

function, and will be faulted if it occurs in any other context.<br />

92 <strong>Pascal</strong> Issue 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!