The FORTRAN–Pascal Interface
203
8
If the procedure is not a top-level procedure, then you do not deal with how to
pass it, because that requires allowing for the static link. A procedure or
function passed as an argument is associated with a static link to its lexical
parent’s activation record.
When an outer block procedure or function is passed as an argument, Pascal
passes a null pointer in the position normally occupied by the static link of the
passed routine. So that procedures and functions can be passed to other
languages as arguments, the static links for all procedure or function
arguments are placed after the end of the conformant array bounds pairs, if
any.
The Pascal main program,
PassProcmain.p
program PassProcmain;
var
a, b: real;
procedure passproc(var u: real; var v: real;
procedure p(var r: real; var s: real));
external fortran;
procedure AddOne(var x: real; var y: real);
begin
y := x + 1
end; { AddOne }
begin
a := 8.0;
b := 0.0;
passproc(a, b, AddOne);
writeln(a: 4: 1, b: 4: 1)
end. { PassProcmain }
The commands to compile and
execute
PassProc.f
and
PassProcmain.p
hostname% f77 -c PassProc.f
PassProc.f
passproc
hostname% pc PassProc.o PassProcmain.p -lpfc -lF77
hostname% a.out
8.0 9.0
Содержание SunSoft Pascal 4.0
Страница 14: ...xiv Pascal 4 0 User s Guide ...
Страница 16: ...xvi Pascal 4 0 User s Guide ...
Страница 30: ...6 Pascal 4 0 User s Guide 1 ...
Страница 160: ...136 Pascal 4 0 User s Guide 6 ...
Страница 268: ...244 Pascal 4 0 User s Guide 11 ...
Страница 320: ...296 Pascal 4 0 User s Guide B ...
Страница 331: ...Index 307 ...
Страница 333: ......