Property List Operations for types
the following provide property list operations for types. Note that using them will invoke the runtime type package.
TypePutProp:
PROC [type: Type ← nullType, prop:
ATOM, val:
REF
ANY];
associates val and prop for type, i.e. TypeGetProp[type, prop] will return val. If type is a ref type, also makes the association with the referent type, so that if TypeGetProp is called with type the referent type and dereferenced = TRUE, it will return val. The purpose of this is to enable you to start with a REF ANY, get the type for its referent, but find the attachment that corresponds to the REF ANY. If the TV interface allowed us to backup from the type of a referent to the type of a REF to that thing, then this would ot be necessary.
TypeGetProp:
PROC [type: Type ← nullType, prop:
ATOM, dereferenced:
BOOLEAN ←
FALSE, ref:
REF
ANY ←
NIL]
RETURNS[
REF
ANY];
returns the indicated association if any. dereferenced=TRUE means that type is the referent type for the object you are interested in. In this case, if the client previously did a type attachment on the reftype, (see above) TypeGetProp will be able to find it.
If type is not specified, ref will be used to compute it (i.e. TVForReferent). In this case, dereferenced is implicitly TRUE.
Miscellaneous
IsAnAtom:
PROC [type: Type, dereferenced:
BOOLEAN ←
FALSE]
RETURNS[
BOOLEAN];
e.g. if x: TYPE = LIST OF REF ANY, and you obtain a tv for the first element of x, its type is of REF ANY. The only way to find out if this is an atom is to ask whether the type of its referent, i.e. Range[type], is the same as that of the type of the range of ATOM. This procedure does that for you. If dereferenced = TRUE, then type is the type of the referent, and in this case the test is whether type is equivalent to the range of ATOM.