next up previous contents
Next: the NeXTSTEP operating system Up: Introduction Previous: the theory of complex

the programming language REC

The programming language REC was derived from LISP over a period of time, and found to be useful for minicomputers such as Digital Equipment's PDP-8, or early microprocessors such as the IMSAI or Polymorphic 88, given its extreme conciseness. That, in fact, is the reason why it is still preserved as an interface to programs written in other languages running with other operating systems.

REC itself is strictly a control structure, using parentheses to group sequences of instructions which are supposed to be executed in order -- in other words, programs. The instructions themselves, which are subdivided into operators and predicates, are not part of the control structure, but are always defined separately to create specialized variants on REC.

Besides the use of parentheses for aggrupation, the two punctuation marks, colon and semicolon, are used for repetition and termination, respectively; they were somewhat borrowed from musical notation. Spaces, tabs, all the C ``white space,'' are used for cosmetic purposes and must be ignored.

There is also a mechanism for defining subroutines; definitions and their associated symbols alternate between a balanced pair of curly brackets, terminating in a main program which remains nameless. Definitions so introduced are valid only within their braces, permitting symbols to be reused over and over again on different levels and in different places. A subroutine is actually executed by prefacing its name with an ``at sign,'' as in @x.

The distinction between operators and predicates is somewhat artificial, made mostly for convenience; a predicate which is always true is an operator. The values true and false of a predicate govern the sequence of operations, true meaning that the text of the program continues to be read in order, consecutively from left to right.

But false makes use of the punctuation, implying a skip to the next colon, semicolon, (or right parenthesis, in their absence) at the same parenthesis level. A colon means repetition starting back at the left parenthesis, a semicolon gives a true termination, realized by going forward to the closing right parenthesis, Arriving at a right parenthesis without the benefit of punctuation gives a false termination, but more generally inverts the action of predicates enclosed in such an interval.

This convention allows negating a predicate: (p) behaves oppositely from p. The other boolean combinations of predicates are easily written; ``p and q'' translates into (pq;), ``p or q'' into (p;q;). Moreover, all programs are predicates, even the main program, thereby reporting their results to the next higher program level, the one in which they occur as a subroutine.

REC/C uses about forty operators, of which only the counter !n! and some comparisons are predicates. They are more easily remembered if they are broken down into specific classes, such as the arithmatical operations, or the evaluation of some predefined functions. The central operating element of REC/C is a pushdown list onto which complex constants will be gathered, later to be evaluated, consulted, or replaced by the results of diverse calculations. The flow of data in and around the stack is shown in figure 7.

binary arithmetic operations
- add top two numbers, leave only their sum
- subtract top two numbers, leave their difference
- multiply top two numbers, leave their product
- divide top two numbers, leave their quotient
- exchange top two items on stack leaving both
unary arithmetic operations on top of stack
- complex conjugate
- negative
- multiply by real factor, as in $xx.x$ f
library of common functions
- hyperbolic cosine
- complex exponential
- fractional linear mapping (z+1)/(z-1)
- complex logarithm
- complex square root
- hyperbolic tangent
push constants onto the stack
- push 1
- push i
- push 0
- push 0.1
- push 0.1 i
- push 0.01
- push 0.01 i
graphical display from the top of the stack
- move to first point of a drawn line
- continue line to additional points
- draw a colored square (one argument)
- draw a small colored square (2 args)
- draw a small stereo square (2 args)
- draw a small circle (one argument)
save and restore constants, adjust top of stack
- Rn to recover nth constant by pushing it
- Sn to save nth constant leaving stack intact
- push by duplicating the top of the stack
- pop the stack by discarding its top element
REC background
- (!n! ... :;) repeat ... n times
- floating point number
set parameter values
- graphic multiplier: $10.0$ M, default
- square size: $1.25$ m, default
- compression threshold (nominal 0.15)
- Is angle a multiple of 90 degrees?
- Is real part an integer?
- Is real part a multiple of 0.1?
- supervise recursive depth

There are several documents available explaining REC [1], including a file in the rec subproject of each of the REC files.

next up previous contents
Next: the NeXTSTEP operating system Up: Introduction Previous: the theory of complex