From: cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!m
Subject: Re: Passing procedures as parameters to procedures.
Date: 4 May 93 19:39:26 GMT [thread overview]
Message-ID: <1993May4.153926.11547@sei.cmu.edu> (raw)
Well, it isn't that you cannot do it at all, it just isn't portable (which
it should be, of course, thus 9X), and restrictions do exist. In particular,
the code that follows only works (on my compiler) for library unit level
parameterless procedures.
Certainly, on some implementations this approach won't work at all, due to
restrictions regarding 'Address for subprograms (at least one always returns
"address zero"). These restrictions are not universal by any means.
The following is for Systems Designers 680X0 compilers:
with system;
package call_backs is
subtype parameterless_procedure is system.address;
procedure sign_in( caller : in parameterless_procedure );
procedure make_calls;
end call_backs;
with call_by_address;
package body call_backs is
callers : array(1..255) of parameterless_procedure;
next : integer range 1 .. 255 := 1;
procedure sign_in( caller : in parameterless_procedure ) is
begin
callers(next) := caller;
next := next + 1;
end sign_in;
procedure make_calls is
begin
for K in 1 .. Next-1 loop
call_by_address( callers(K) );
end loop;
end make_calls;
end call_backs;
All well and good, you say, but what is this "call_by_address" procedure?
It uses package Machine_Code to do a JSR to the desired routine, and uses
an implementation-defined mechanism (the pragma) to associate the parameter
(callee) with the register (A0) used in the JSR. Other implementations
would use a different format for the JSR and for the parameter association
mechanism...
with System;
with Machine_Code;
procedure call_by_address( callee : in system.address ) is
use Machine_Code;
begin
EA_INST'( Mode => A0_Indirect, Opcode => JSR );
end call_by_address;
pragma Inline( Call_By_Address );
pragma Call_Sequence_Procedure( unit => call_by_address,
parameter_types => (system.address),
mechanism => ( Value (A0) )
);
next reply other threads:[~1993-05-04 19:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-05-04 19:39 cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!m [this message]
-- strict thread matches above, loose matches on Subject: below --
1993-05-10 22:56 Passing procedures as parameters to procedures Jack Dean
1993-05-06 9:39 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!howland.reston.ans.net!darwi
1993-05-06 7:33 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!howland.reston.ans.net!torn!
1993-05-05 21:35 cis.ohio-state.edu!news.sei.cmu.edu!ajpo.sei.cmu.edu!progers
1993-05-05 17:39 Robert Dewar
1993-05-05 17:35 Robert Dewar
1993-05-05 16:30 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!us
1993-05-05 11:40 cis.ohio-state.edu!news.sei.cmu.edu!firth
1993-05-05 9:50 cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!howland.
1993-05-04 23:44 cis.ohio-state.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state.edu!ho
1993-05-04 22:13 John Goodsen
1993-05-04 16:41 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!howland.reston.ans.net!ira.u
1993-05-04 16:25 Mark A Biggar
1993-05-04 15:43 Tucker Taft
1993-05-04 14:29 cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!uwm.edu!spool.mu.edu!
1993-05-04 13:59 Tucker Taft
1993-05-04 13:45 cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!howland.
1993-05-04 13:45 cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!uwm.edu!cs.utexas.edu
1993-05-04 10:25 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!us
1993-05-03 20:36 Mark A Biggar
1993-05-03 19:07 cis.ohio-state.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state.edu!ho
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox