next up previous contents
Next: Procedures which produce Up: CHAPTER.2: INTRODUCTION TO Previous: Procedure calls in

Using infix operators

In the imperative

    3 + 4 =>
the symbol "+" acts as the name of a built-in procedure to be applied to the numbers 3 and 4. The symbol "+" is called an `infix operator' because you can run the procedure by writing the name between the inputs, although the following "parenthesised prefix" syntax would work just as well:

    +(3, 4) =>
    ** 7
Just as "+" can be used for addition, so can the asterisk "*" be used as an infix operator for multiplication. So:

    3 * 5 =>
    ** 15
    999 * 999 =>
    ** 998001
Pop-11 provides many built in procedures whose names function as infix operators. Other examples are the equality predicates "=" (which tests for the same type of object with equal components), "==" (which tests for the very same object), the STRING concatenator "><", the generic structure concatenator "<>", the list constructor "::", and other arithmetic operators for division "/", remainder "rem", subtraction "-" and exponentiation "**". (That is not a complete list.)

Infix operators have a numerical precedence which determines how they should be grouped if combined in complex expressions, like "x + y * z", and this is explained in Chapter 4. Chapter 4 also shows how users can define their own infix operators.



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