Atom.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Warren Teitelman, October 26, 1982 4:15 pm
Paul Rovner September 19, 1983 8:43 pm
Russ Atkinson (RRA) January 31, 1985 2:30:17 pm PST
Beach, February 23, 1985 9:33:07 am PST
Doug Wyatt, February 24, 1985 8:14:50 pm PST
DIRECTORY
Rope USING [ROPE, Text];
Atom: CEDAR DEFINITIONS
= BEGIN
Atoms provide a means for canonicalizing ropes. Because of the support for ATOM literals, atoms provide a fast and easy means for testing against a small set of keywords.
As in Lisp, atoms can also have property lists, although this usage is discouraged, since multiple applications can have their property lists collide to mutual discomfort. An alternative (and usually preferable) 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 RefTab.
Types
ROPE: TYPE = Rope.ROPE;
Text: TYPE = Rope.Text;
PropList: TYPE = LIST OF DottedPair;
DottedPair: TYPE = REF DottedPairNode;
DottedPairNode: TYPE = RECORD [key, val: REF ANY];
Creating Atoms
EmptyAtom:
PROC
RETURNS[
ATOM];
... returns the atom with pname = ""
MakeAtom:
PROC [pName:
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: CHAR] RETURNS [ATOM];
MakeAtomFromRefText: PROC [rt: REF READONLY TEXT] RETURNS [ATOM];
PNames
GetPName: PROC[atom: ATOM] RETURNS[pName: Text];
Property list operations
GetPropertyList: PROC [atom: ATOM] RETURNS [PropList]; -- 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];
Enumeration of atoms
MapAtoms: PROC[proc: PROC[atom: ATOM]];
FindAtom: PROC[proc: PROC[atom: ATOM] RETURNS [stop: BOOL]] RETURNS[ATOM];
Errors
NILNotAnAtom: ERROR;
END.