Keywordoperations
Description
A record may contain a special 'operations' component which in turn is a record that contains functions. These functions are called when this record is an operand of '+', '-', '*', '/', '^', 'mod', 'in', 'Print', '=', '<'. In the 'operations' the names of the components of '+', '-', '*', '/', '^', '=', '<' have to be quoted, i.e., written as '\+', '\-' and so on. The unary '-a' is computed as '0-a','a <= b' is 'a < b or a = b', 'a > b' is 'not a < b', etc.
Examples
o := rec();
o.\+:= function(a,b) return rec(n :=2*a.n+b.n, operations := o); end;
r := rec(n:=3, operations:=o); s:= rec(n:=4, operations := o);
r+s; s+r;
|