Express.mesa
Express provides the client a way to evaluate an arithmetic expression given in a rope (generally from the user), typically faster than Interpreter or JaM, especially if the same function is used repeatedly.
Created Thursday, June 28, 1984 10:25 am PDT
Last edited by Eric Nickell, July 17, 1984 9:54:43 pm PDT
DIRECTORY
Rope USING [ROPE];
Express: CEDAR DEFINITIONS ~ {
OPEN R: Rope;
ROPE: TYPE ~ R.ROPE;
Symbols: TYPE ~ LIST OF ROPE;
Fcn: TYPE ~ PROC [a,b,c,d,e: REAL ← 0] RETURNS [z: REAL];
Someday, hopefully, this type will become more general
ParseError: ERROR [error: ErrorDesc];
ErrorDesc: TYPE ~ RECORD [
reason: ROPE,
position: INT
];
IllegalClientProcedure: ERROR;
ClientProc: TYPE ~ RECORD [
proc: PROC ANY RETURNS [REAL],  --Actually ANY must be 1 or 2 REALs
userRope: ROPE        --What client's user will call it
];
ClientProcList: TYPE ~ LIST OF ClientProc;
RopeToFcn: PROC
[
expression: ROPE,
symbols: Symbols,      --Up to five, corresponding to a,b,c,d,e
cProcs: ClientProcList ← NIL,
oldFcn: Fcn ← NIL
]
RETURNS [fcn: Fcn];
This is the parsing procedure, and is therefore fairly expensive. Time is spent here, so that it may be save in EvalFcn below.
The algebraic constructs available are now documented here, as they are changing periodically, which makes documenting in the interface a poor idea, unfortunately. The current stuff can be found in ExpressDoc.
symbols is the list of ROPEs that identify the arguments, IN THE ORDER they will be passed to EvalFcn.
oldFcn, if provided, will inform the system that you have no further need of that procedure. (Unfortunately, Express can't tell about the dangling reference problem. Oh, well.) RopeToFcn may return the same procedure (possibly tweeked) as you gave it (if you were generous enough to give it anything), or it may not.
Clients: Once you get fcn back into the privacy of your own module, then calls of the form
fcn[a,b,c,d,e]
will get you a result...
FreeFcn: UNSAFE PROC [fcn: Fcn];
Deallocates the procedure. Do not do this if the function will be passed back as oldFcn to RopeToFcn.
}.