5.3 Statements, forms

An additional way to link symbolic entries to algebraic mode is to invent a new syntactical unit. A REDUCE statement is introduced by assigning the property stat = rlis to the leading keyword of the new statement. The corresponding function will be called with one parameter which is a list of the (unevaluated) parameters of the statement. A statement normally is called for its side effect rather than for its value - so the result will be not interpreted as an algebraic quantity (ws not set, printed as symbolic list etc.). Example:

   symbolic procedure my_add u;  
     begin scalar r;  
        r:= 0;  
        for each x in u do  
        <<x:=reval x;  
        return r;  

to be called by a statement

   my_add x,x^2,x^3;

A statement without parameters is introduced by the property - value pair stat = endstat because the statement “end” is the most prominent representative of this class.

For a more complicated syntax you can write a function which preprocesses a statement before evaluating it. Such preprocessors are linked to the leading keyword by the property formfn. However writing a formfn is rather difficult as you will have to organize the reading of the rest of the statement yourself. This approach is not recommended as the formfn interface is rather delicate and might be subject to future changes.