Search                        Top                                  Index
HELP ROUNDBRA                                       Steven Hardy, March 1982

Round brackets, ( and ) , have two uses in POP-11.

Firstly, they can be used to alter the order of evaluation when using infix
procedures. For example:

    2 + 3 * 4 =>
    ** 14
    (2 + 3) * 4 =>
    ** 20

Secondly, they are used to indicate that a procedure is to be applied to some
arguments. The syntactic form:

    <expression> (<arguments>)

means 'evaluate the expression and apply the result to the arguments'.
Normally the expression is simply the name of a variable. It can however be
as complex as desired. Note that:


means 'apply FOO to X, and apply the result to Y'.

The second use can be modified by adding 'percent' symbols to the brackets,

    <expression> (% <arguments> %)

In this case the procedure is not run immediately. Instead a new procedure is
created, a CLOSURE, which is a combination of the old procedure and the
arguments. E.g. from the procedure

    member("cat", [dog mouse cat pig]) =>
    ** <true>

we can form a 'closure' by partially applying MEMBER to the list
[cat dog mouse pig]. The result is a procedure which we can call ISANIMAL.

    vars isanimal;
    member(%[dog mouse cat pig]%) -> isanimal;

    isanimal("dog") =>
    ** <true>

    ** <false>

See TEACH *BRACKETS for a tutorial introduction to the use of brackets in

See also HELP
    *SQUAREBRA and
    *TWIDDLYBRA - for other types of brackets in POP-11 syntax
    *PARTAPPLY - for a summary of partial application
    *CLOSURES  - for details of closures
    *PERCENT  - for uses of the % symbol in POP-11