billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu (William Thomas Wolfe,2847,) (08/28/89)
Randall described a few environments which provide "lightweight tasks"; in such an environment, one can pretty much be unconcerned with the inability to directly invoke Ada subprograms by way of pointers, since one can simply enclose the desired subprogram in a task body; this gives complete flexibility, since one can store a pointer to a task and later invoke the task via the pointer, or even store the task itself as a record component and then invoke it directly. This, of course, is completely portable, unlike the situation in which one insists upon keeping the code in the form of a subprogram and must therefore resort to machine language in order to get the subprogram invoked by way of its 'ADDRESS (or by way of a pointer). Assuming that lightweight tasking is provided (and Ada is largely based upon this assumption, certain obsolescent operating system technology notwithstanding), there is really no particularly compelling reason to require the ability to invoke subprograms by way of a pointer, except perhaps as part of some aesthetic desire for orthogonality. Bill Wolfe, wtwolfe@hubcap.clemson.edu
arra@stellar.COM (Arra Avakian @stellar) (08/31/89)
Bill Wolfe, wtwolfe@hubcap.clemson.edu, writes in referencing to calling a function given its address: > ... 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. > It seems there is a syntax in Ada for calling a subprogram, given its address at run time. However, it depends upon an interpretation of an address clause for a subprogram that may not be what was intended in the ARM (13.5), paragraph 5: "b) Name of a subprogram, package, or task unit: the address that is required for the machine code associated with the body of the program unit." I believe that was is intended is that the corresponding body, which is expected to occur later, will be placed in some system dependent manner by a linker/loader at the given (presumably static) address. However, another interpretation is that the body will NOT be supplied in Ada, but that the machine code for it will be found at the given (possibly non-static) address. So here it is (a different version for every signature is required, only one example given): -- -- "call(p,i)" will call a procedure given by address "p" with argument "i" -- with SYSTEM; procedure CALL(PROC: SYSTEM.ADDRESS; ARG: INTEGER) is -- Define a dummy procedure at address "PROC" procedure DUMMY(I: INTEGER); for DUMMY use at PROC; begin DUMMY(I => ARG); end CALL; ========================= arra@stellar.com Arra Avakian Stellar Computer Inc 95 Wells Ave Newton, MA 02159 (617) 964-1000 xt 288