<<>> <> <> <> <<>> DIRECTORY SafeStorage, IO, Atom, Rope, Basics, Imager, MathExpr, MathObjects; MathObjectsImpl: CEDAR PROGRAM IMPORTS Rope EXPORTS MathObjects = BEGIN <> ROPE: TYPE = Rope.ROPE; STREAM: TYPE = IO.STREAM; <> ObjectRep: TYPE = RECORD [ class: Object _ NIL, data: REF _ NIL ]; Object: TYPE ~ REF ObjectRep; -- inside impl module, use rep <<>> MethodRep: TYPE = RECORD [ staticType: ATOM, name of method's "static signature", which is a specification of the numbers (arities) of its inputs and outputs, and some information about their "types". I.e. static signatures denote families of similar methods. Used for "dispatch on name of static signature" invocation of methods (following verfication that actual parameters conform to this method's "dynamic signature", which is computed afresh at each invocation of this method) via a global Alist of method types and corresponding method apply procs. The actual ATOM here is a selector into that global AList. <> <> ApplyToObject: PROC [method: REF, structure: Object, argList: LIST OF Object, recast: BOOL] RETURNS[value: Object]; m: Method; ok: BOOL _ TRUE; IF NARROW[method, Method] THEN m _ method ELSE m _ LookupMethodInStructure[method, structure]; -- FALSE => method arg is actually an ATOM methodSelector; use it to lookup the method IF recast THEN [ok, outArgs] _ RecastArgs[m, structure, argList] ELSE outArgs _ argList; IF ok THEN <> ELSE ERROR; <<>> attributes: Atom.PropList, <<"constant" attributes stored e.g. as [$commutative, $commutative]; NIL value field would confuse with absence of attribute>> dynamicType: REF UnaryToTwoListsOp _ NIL, <> <> <> <> <> <> <> <> If output LIST OF arg Structures has i < n = (# args this method) Structures, then args i, i+1, ..., n expected to belong to last (ith) Structure of the list (useful e.g. for vector and matrix constructors). <> <<>> value: REF -- REF Proc The "impl" of the method ]; Method: TYPE ~ REF MethodRep; -- inside impl module, use rep <<>> MethodDictionaryRep: TYPE = Atom.PropList; MethodDictionary: TYPE = REF MethodDictionaryRep; <<>> END.