In comp.lang.pop, Monika Sester writes: (text slightly edited for brevity)
> I want to write a procedure which executes an unknown number
> of functions. The names of these functions are stored in the database.
>
> What I tried is to do it with the following procedure:
>
> foreach [execute ?function ?input ?output] do
> valof(function)(argument) -> result;
> endforeach;
The number of input locals of a function is accessible via the procedure
-pdprops- (derivation: pd = ProceDure, props = PROPertieS). e.g.
pdprops( conspair ) =>
** 2
There is no corresponding field for the number of output parameters because
it is easy to calculate. Simply gather the output results together and
take the length of the single result.
[% "foo" <> "bar" %] -> result;
length( result ) =>
** 1
Alternatively, use the "count bracket" syntax. This is the modern and
efficient way of doing it.
#| "foo" <> "bar" |# -> nresults;
Note that this technique leaves the result(s) on the stack.
I imagine that the new code might look something like this ....
foreach [execute ?function] do
lvars f = valof( function );
lvars nargs = pdprops( f );
lvars results = [% f( get_n_arguments( nargs ) ) %];
endforeach;
Hope this helps,
Steve
|