Article View: comp.sw.components
Article #57Re: Inheritance vs. component effic
From: Robert Eachus
Date: Mon, 28 Aug 1989 20:35
Date: Mon, 28 Aug 1989 20:35
51 lines
2515 bytes
2515 bytes
In article <6339@hubcap.clemson.edu> billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu writes:
>From an earlier article by me:
>> [regarding storing pointers to subprograms in Ada]
>> The major restriction, then, is not an inability to store a pointer to
>> a function in a record type; rather, it is the fact that there is not
>> a mechanism which can express the desire to invoke the function residing
>> at that address; the 9X proposed revision would therefore provide such a
>> mechanism.
>
> Actually, even this isn't strictly true; since Ada provides a
> mechanism for arbitrary machine-code insertions, it is quite
> possible to load the address of the desired subprogram into a
> register, direct the CPU to execute the subprogram, and finally
> store a pointer to the results for subsequent use; it's just that
> there's no way to do it while still preserving portability...
Try the following trick:
.....
function Something_or_Other (X: in Integer) return Integer;
SOO_Address: Address := Something_or_Other'ADDRESS;
procedure Foo (Some_Address: System.Address; T in out Integer) is
function Local (X: in Integer) return Integer;
pragma INTERFACE(C, Local);
for Local'ADDRESS use Some_Address;
begin
T := Local(T);
end Foo;
....
The LRM says that this is legal Ada (assuming C is a legal argument
to pragma INTERFACE), but it doesn't mandate the semantics. However,
I can't imagine any compiler not calling Something_or_Other at the
point of the call to Local. The calling conventions on a particular
machine may be different for C and Ada though. In fact some compilers
permit pragma INTERFACE(Ada,....) for just this reason...
Robert I. Eachus
with STANDARD_DISCLAIMER;
use STANDARD_DISCLAIMER;
function MESSAGE (TEXT: in CLEVER_IDEAS) return BETTER_IDEAS is...
Technical Details
Message-ID:
<66136@linus.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!att!dptg!rutgers!cs.utexas.edu!uunet!peregrine!ccicpg!conexch!zardoz!tgate!ka3ovk!drilex!axiom!linus!mbunix!eachusReferences:
<6333@hubcap.clemson.edu> <6339@hubcap.clemson.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!att!dptg!rutgers!cs.utexas.edu!uunet!peregrine!ccicpg!conexch!zardoz!tgate!ka3ovk!drilex!axiom!linus!mbunix!eachus From: eachus@mbunix.mitre.org (Robert Eachus) Newsgroups: comp.sw.components Subject: Re: Inheritance vs. component effic Summary: Yes it is possible, and it SHOULD be portable... Keywords: Ada procedure parameters... Message-ID: <66136@linus.UUCP> Date: 28 Aug 89 20:35:49 GMT References: <6333@hubcap.clemson.edu> <6339@hubcap.clemson.edu> Sender: news@linus.UUCP Reply-To: eachus@mbunix (Robert I. Eachus) Organization: The MITRE Corporation, Bedford, Mass. Lines: 51