valof-question 
Author Message
 valof-question

In comp.lang.pop, Monika Sester writes: (text slightly edited for brevity)

Quote:
> 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



Sun, 20 Aug 1995 01:38:56 GMT  
 valof-question
hi,
i have a nice pop11-problem:
i want to write a procedure which executes an unknown number
of funktions.
the names of these functions are stored in the database.
(furthermore the number of input and output - parameters
could also be given).
  [execute function #input #output]

what i tried now is to do it with the following procedure:

      foreach [execute ?function ?input ?output] do
         valof(function)(argument) -> result;
      endforeach;

i managed to get the output-parameters from the stack.
this works fine, as long as i have only one input-argument.

the question is now, how to write the procedure in order to
handle a flexible number of input arguments ?

(nb.: do i explicitely have to store the number of input and
output-parameters, or is there a routine that extracts it for
me ? )



Sat, 19 Aug 1995 21:09:27 GMT  
 valof-question

Quote:

> The number of input locals of a function is accessible via the procedure
> -pdprops- (derivation: pd = ProceDure, props = PROPertieS).  e.g.

>     pdprops( conspair ) =>
>     ** 2

Got that wrong Steve.

    pdprops(conspair) =>
    ** conspair
    pdnargs(conspair) =>
    ** 2

derivation: ProceDure Number ARGumentS - or something :-)                    

In comp.lang.pop, Monika Sester writes: (text slightly edited for brevity)

Quote:
> 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;

As a comment to this (in case you didn't know - apologies if you
did), procedures in Pop11 are first class data types. You can store them              
in lists just like any other data.

Also, I don't understand from your example where you get the value
of -argument- from. As a programming exercise (which is no doubt
nothing like what you're doing :) let's say that the arguments are
also stored in the list along with the real procedure (not it's
name). We then get:

    foreach [execute ?func ??args] do
        [% func(explode(args)) %] -> results;
    endforeach;

Ian.



Sun, 20 Aug 1995 22:19:26 GMT  
 valof-question

Quote:
> >     pdprops( conspair ) =>
> >     ** 2
> Got that wrong Steve.

Ummm .... it's a fair cop, I'll come quietly occifer.

Apologies to Monica for this mental glitch & thanks to Ian for pointing
out that I should be using "pdnargs" to find the number of arguments
and not "pdprops".

Steve



Mon, 21 Aug 1995 22:48:37 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. valof evil?!

2. valof evil ?!

3. valof

4. Questions-Questions-Questions-Answers-Answers

5. Question(Questions, questions...)

6. Newbie Question: Realbasic Question

7. Questions Questions

8. Questions and more questions...

9. Browse Question / Report question

10. ***Data buffering question. Long post, lots of questions

11. questions, questions!

12. Questions, questions!

 

 
Powered by phpBB® Forum Software