MathTypeResolution.mesa
Copyright © 1989 by Xerox Corporation. All rights reserved.
Arnon, August 28, 1989 1:42:36 pm PDT
DIRECTORY
SafeStorage,
IO,
Atom,
Rope,
Basics,
MathObjects;
MathTypeResolution: CEDAR DEFINITIONS
= BEGIN
Provides a type resolution algorithm.
Type resolution problems are of two types (we assume args and results are Elements, not Structures):
"Bound": we are given a particular Domain or View S, and a particular Element Object O, and we want to know if O can be converted (recast) to be an Element of S.
"Free": we are given a methodKey $foo, a list A of actual arg Element Objects, possibly an initial Domain, View, or Category, and we seek a Structure S which has a Method $foo, such that we can succeed at the "Bound" problem of converting the components of A to match foo$[S]'s runtimeType. Of course we hope that we can succeed using our initial given candidate for S, or a Structure to which some element of A belongs.
Capabilities are based on:
(1) the currently instantiated Domains, Views, Categories (with their attendant collections of Methods),
(2) the current system (global) Domain and Category lattices,
(3) currently known Packages,
(4) other means of Method lookup,
(5) possibly other sources of rules and heuristics.
Currently Categories do not enter into type resolution at all. Categories do however enter into type conversion activities (which are completely guided by the current Domain and Category lattices), e.g. if a component of a method's runtimeType is a Category, then we will try to see if the actual parameter is an Element of a Domain or View which can be viewed as an element of that Category.
A special case of type resolution is "type inference", i.e. the attempt to have the system determine alternative (usually narrower) types for an Object.
The most common case of this is starting with an Object of type Expr. We begin with the obvious ability of MathExprs to associate types with the atomic "leaves" of the Expr. From this point on, we are doing type resolution as above.
A desired consistency principle in the system: For any object O,
O = TypeResolve[O.class.EltToExpr[O] ]
Types From Referenced Interfaces
ROPE: TYPE = Rope.ROPE;
STREAM: TYPE = IO.STREAM;
Object: TYPE = MathObjects.Object;
MethodDictionary: TYPE = MathObjects.MethodDictionary;
END.