PropList: CEDAR DEFINITIONS ~ BEGIN List: TYPE = REF ListContainer; ListContainer: TYPE; IsPropList: PROC [x: REF] RETURNS [BOOL]; NarrowPropList: PROC [x: REF] RETURNS [List]; NewPropList: PROC [] RETURNS [List]; NewCopy: PROC [list: List ¬ NIL] RETURNS [List]; GetProp: PROC [list: List, key: REF] RETURNS [REF]; PutProp: PROC [list: List, key, val: REF] RETURNS [REF]; RemProp: PROC [list: List, key: REF] RETURNS [REF]; ConditionalPutProp: PROC [list: List, key, expect, new: REF] RETURNS [val: REF, done: BOOL]; InitializeProcType: TYPE ~ PROC [data: REF, key: REF] RETURNS [val: REF ¬ $x]; GetPropOrInit: PROC [list: List, key: REF, init: InitializeProcType, data: REF ¬ NIL] RETURNS [val: REF, done: BOOL]; EachPropProc: TYPE = PROC [data: REF, key, val: REF] RETURNS [quit: BOOL ¬ FALSE]; Enumerate: PROC [list: List, map: EachPropProc, data: REF ¬ NIL] RETURNS [quit: BOOL ¬ FALSE]; TrustedAddNewProp: PROC [list: List, key, val: REF]; NiloutPropList: PROC [list: List]; END. 2 PropList.mesa Copyright Σ 1992 by Xerox Corporation. All rights reserved. Created by Christian Jacobi, April 9, 1992 11:48:58 am PDT Christian Jacobi, April 15, 1992 3:24 pm PDT Property lists to store arbitrary key value pairs. Creates a new property list and initializes it with a copy of list. Fetches a value from the property list; returns NIL if not found. Puts a property (key value pair) on the property list and returns the previous value. A NIL value removes the property. Like PutProp[listAddr, key, NIL] Atomically val ¬ GetProp[listAddr, key]; done ¬ (val=expect); IF done THEN [] _ PutProp[listAddr, new]; Type used for procedure initializing property. Atomically executes init exactly when the property list has no key property, then puts the return value as key property. (Atomic versus other calls of GetPropOrInit using the same listAddr and the same key only). Returns value of property, and, whether init was called. Simple calls of PutProp, RemProp, ConditionalPutProp, NiloutPropList etc. even with the same key are not blocked while init executes. However, of course, the value returned from init is put on the list atomically versus all other operations. Type used for procedure enumerating properties on list. Enumerate the key value pairs of the property list in unspecified order. Quits enumerating and returns TRUE if map returns TRUE. Like PutProp except the caller is trusted that key is not found on property list (no checking). This is useful to avoid n**2 cost algorithms, and, can be used e.g. when a key was just created with NEW. In case of violation, the property list might end up with multiple entries for the key, which might cause any PropList procedure to handle either, none or multiple values. However this would not cause PropList to crash. Like list­ ¬ NIL, but better Κ²•NewlineDelimiter –(cedarcode) style™codešœ ™ Kšœ Οeœ1™