ISO Pascal reference manual
ISO Pascal reference manual
ISO Pascal reference manual
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 6<br />
TYPE<br />
IntRef =tInteger;<br />
FNCParams = RECORD p1, p2: IntRef END;<br />
VAR<br />
FNCParamBlock: FNCParams;<br />
IMPORT FUNCTION FNC (VAR p: FNCParams): IntRef;<br />
PROCEDURE LocalFNC (n1, n2: Integer): Integer;<br />
VAR<br />
rp: IntRef;<br />
BEGIN<br />
WITH FNCParamBlock DO BEGIN pit := a; p21:= b; END;<br />
rp := FNC (FNCParamBlock);<br />
LocalFNC = rpi;<br />
END;<br />
BEGIN<br />
WITH FNCParamBlock DO BEGIN NEW (p1); NEW (p2) END;<br />
WITH FNCParamBlock DO BEGIN DISPOSE (p1); DISPOSE (p2) END;<br />
END.<br />
In this version, the total cost of an individual call on LocalFNC has been<br />
reduced to a modest level, but at some cost in terms of program clarity.<br />
However the program does remain within the bounds of what is nominally<br />
`legal' <strong>Pascal</strong> (ignoring the IMPORT mechanism itself). An alternative, but<br />
less 'clean' method is to use an extension of the <strong>Pascal</strong> compiler which<br />
permits the calculation of the run-time address of a variable, as below:<br />
TYPE<br />
IntRef =iInteger;<br />
FNCParams = RECORD p1, p2: Integer END;<br />
IMPORT FUNCTION FNC (VAR p: FNCParams): IntRef;<br />
FUNCTION LocalFNC (a, b: Integer): Integer;<br />
VAR rp: IntRef;<br />
paramBlock: FNCParams;<br />
BEGIN<br />
paramBlock.p1 := ADDRESS (a);<br />
paramBlock.p2 := ADDRESS (b);<br />
44 <strong>Pascal</strong> Issue