Atom.Mesa
last edited October 26, 1982 4:15 pm by Warren Teitelman
DIRECTORY
RTBasic USING [Type, nullType],
Rope USING [ROPE, Text],
List USING [AList];
Atom: CEDAR DEFINITIONS IMPORTS Rope =
BEGIN
Types
PropList: TYPE = List.AList;
NILNotAnAtom: ERROR;
Creating Atoms
emptyAtom: ATOM; -- atom with pname = ""
MakeAtom: PROC [pName: Rope.ROPE] RETURNS[ATOM];
The following identity holds: Rope.Equal[r1,r2] <=> MakeAtom[r1] = MakeAtom[r2]. In particular, MakeAtom[""] = MakeAtom[NIL] = emptyAtom. Note that NIL # MakeAtom[NIL].
MakeAtomFromChar: PROC [char: CHARACTER] RETURNS[ATOM];
IsAnAtom: PROC [type: RTBasic.Type, dereferenced: BOOLEANFALSE] 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.
Gensym: PROC [c: CHARACTER ← 'A] RETURNS[ATOM];
returns a new atom of the form c000n, incrementing n each time.
PNames
GetPName: PROC[atom: ATOM] RETURNS[pName: Rope.Text];
Length: PROC [self: ATOM] RETURNS[LONG INTEGER];
number of characters in pname
property list operations
provides a way of associating information with unique keys (atoms) using a single global name space.
Note: An alternative way of associating information with unique keys...
that can be arbitrary REFS, in a non-global fashion using specific structures (hash tables) is provided by the RefTab interface, which is also exported by ListsAndAtoms.bcd
GetPropertyList: PROC [atom: ATOM] RETURNS[List.AList]; -- gets entire property list
GetProp: PROC [atom: ATOM, prop: REF ANY] RETURNS[REF ANY];
GetPropFromList: PROC [propList: PropList, prop: REF ANY] RETURNS[REF ANY];
PutProp: PROC [atom: ATOM, prop: REF ANY, val: REF ANY];
PutPropOnList: PROC [propList: PropList, prop: REF ANY, val: REF ANY] RETURNS[PropList];
RemProp: PROC [atom: ATOM, prop: REF ANY];
RemPropFromList: PROC [propList: PropList, prop: REF ANY] RETURNS[PropList];
Property List Operations for types
the following provide property list operations for types. Note that using them will invoke the runtime type package.
TypePutProp: PRIVATE PROC [type: RTBasic.Type ← RTBasic.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: PRIVATE PROC [type: RTBasic.Type ← RTBasic.nullType, prop: ATOM, dereferenced: BOOLEANFALSE, ref: REF ANYNIL] 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.
enumeration of atoms
MapAtoms: PROC[proc: PROC[atom: ATOM]];
FindAtom: PROC[proc: PROC[atom: ATOM] RETURNS[stop: BOOLEAN]] RETURNS[ATOM];
END.
change log
10-Feb-82 14:47:48 added zone for atoms. Changed all prop arguments from ATOM to REF ANY. Added pointer to Paxtons Reftab.
18-Feb-82 12:14:50 changed GetPName to return Rope.Text instead of REF TEXT
June 1, 1982 3:28 pm name of argument to MakeAtom changed from ref to pName
August 31, 1982 1:51 pm TypePutProp, TypeGetProp now private.