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.
6.3 Interfacing to Panos standard procedures<br />
Using <strong>Pascal</strong> with other languages<br />
To convert a procedure call specification given in abstract form (e.g. one<br />
from the Panos Programmer's Reference Manual) into a form suitable for<br />
use in a <strong>Pascal</strong> IMPORT statement, the following process should be<br />
applied. (Note that standard procedures having procedure-type parameters<br />
cannot be called from <strong>Pascal</strong>, and so should not be imported, and <strong>Pascal</strong><br />
procedures with procedure-type parameters similarly cannot be called from<br />
a non-<strong>Pascal</strong> environment, and so should not be exported other than to<br />
another <strong>Pascal</strong> module. This is because procedures in the calling standard<br />
are passed purely by descriptor (they are not closures, i.e. there is no value<br />
environment in which they expect to operate), whereas <strong>Pascal</strong> procedure<br />
parameters are passed as full closures, and not in the standard manner.<br />
1. Write down the abstract specification of the procedure.<br />
2. If the type of any parameter or result includes the structure<br />
RECORD( < format >), write a suitable record type specification in <strong>Pascal</strong><br />
for each such format. If the form 'RECORD( < format >) REF' occurs,<br />
also define a type < rec_type > _ref as < rec_type > '. Rewrite the<br />
specification using these new type names instead of the original forms, and<br />
change the abstract syntax into the <strong>Pascal</strong> form, i.e. < param_name > :<br />
< type ><br />
3. If any parameters are of type STRING, then for each:<br />
(a) decide on the maximum length of string which will be supplied to the<br />
procedure from this module, for that parameter;<br />
(b) define a type String < N > (if it does not already exist), where < N > is<br />
the maximum length decided on in (a), and the type is defined as<br />
PACKED ARRAY [1.. < N > OF Char;<br />
(c) rewrite the parameter specification as two items: the first having the<br />
original parameter name, but written in <strong>Pascal</strong> form, with its type<br />
being String < N > ; the second having the parameter name with '_len'<br />
appended, of type Integer, i.e. 'STRING: < par_name > ' is rewritten as<br />
< par_name > : String < N >; < par_name > _len: Integer'.<br />
4. If any parameters or results are of type HIDDEN, CARDINAL or<br />
INTEGER, rewrite these parameter specifications as the parameter name<br />
followed by the type Integer, e.g. 'HIDDEN: < par_name > ' becomes<br />
< par_name > : Integer', and so on.<br />
<strong>Pascal</strong> Issue 1 39