next up previous contents
Next: Procedures with more Up: CHAPTER.4: PROCEDURES IN Previous: Specifying the syntactic

Executing (calling, running, applying) a procedure

An imperative telling Pop-11 to run, or invoke, a procedure, is formed by writing the procedure name, followed by parentheses, with any arguments (if any are needed) between the parentheses. E.g.

    square(5);
I.e.: execute the procedure square with 5 as argument. i.e. the input variable, or formal parameter, used in the procedure definition, namely side, gets the value 5. Similarly, we can invoke doublesum with two arguments, both numbers:

    doublesum(3,99) =>
    ** 204
I.e.: execute the procedure doublesum, with 3 and 99 as arguments. I.e num1 gets the value 3 and num2 the value 99. The result (204) is printed out by =>

Instead of printing out the result, we can assign it to a variable, e.g. x, thus:

    doublesum(4, 60) -> x;
Alternatively the result of doublesum can be used as input to another procedure, such as square, as in

    square(doublesum(4, 60));
Note that this is equivalent to:

    4, 60, doublesum(), square();


Aaron Sloman
Fri Jan 2 03:17:44 GMT 1998