next up previous contents
Next: Assignment as a Up: CHAPTER.3: PROCEDURES AND Previous: Procedures communicate via

The DOT-notation for procedure calls

Readers familiar with the language FORTH, you may be interested that Pop-11 admits an alternative notation for procedure calls, sometimes described as "postfix" or "reverse polish" notation. This involves placing arguments, separated by commas, before procedure names and preceeding procedure names with a dot "." to indicate that the procedure is to be applied.

E.g. instead of:

    perim(3,5) =>
you can use

    3, 5 .perim =>
I.e. the "." can be used to invoke a procedure. Thus Pop-11 allows, instead of `sin(45)', `45.sin', which can be interpreted as put 45 on the stack and then run SIN. Similarly

    sin(sqrt(100))
can be expressed as

    100.sqrt.sin

    sin(sqrt(100)) =>
    ** 0.173648

    100.sqrt.sin =>
    ** 0.173648
The dot notation corresponds more closely to the actual order of processing, though the former is the more conventional way of representing procedure calls. We shall not use this POSTFIX notation in this introduction, though it is popular with some Pop-11 users.

Note that if infix operators are used in postfix notation, dots are not required, e.g.

    2 * 3 + 4 * 5 =>
is equivalent to

    2, 3 *, 4, 5 * + =>
The two can be mixed:

    sqrt(3) + 5
is the same as

    3.sqrt, 5 +
Although some Pop-11 users like the postfix notation, it can make programs obscure if used excessively. A common convention is to use it only for accessing components of datastructures, as in the following expression denoting the second element of list:

    list.tl.hd


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