ImmutablePropListImpl.mesa
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
Doug Wyatt, March 26, 1985 5:32:52 pm PST
DIRECTORY
Atom USING [DottedPairNode, PropList],
ImmutablePropList USING [];
ImmutablePropListImpl: CEDAR PROGRAM
EXPORTS ImmutablePropList
~ BEGIN
This property list mechanism regards a PropList as an immutable value. We don't use the procedures from Atom since 1) they might smash an existing PropList, and 2) they hold a global monitor in AtomImpl.
PropList: TYPE ~ Atom.PropList;
Put:
PUBLIC
PROC[propList: PropList, key:
REF, val:
REF]
RETURNS[PropList] ~ {
RETURN[CONS[NEW[Atom.DottedPairNode ← [key: key, val: val]], propList]];
};
Get:
PUBLIC
PROC[propList: PropList, key:
REF]
RETURNS[val:
REF] ~ {
FOR list: PropList ← propList, list.rest
UNTIL list=
NIL
DO
IF list.first.key=key THEN RETURN[list.first.val];
ENDLOOP;
RETURN[NIL];
};
Rem:
PUBLIC
PROC[propList: PropList, key:
REF]
RETURNS[PropList] ~ {
RETURN[Put[propList, key, NIL]];
};
END.