exported by AMExtrasImpl. should be merged with AMTypes
Edited by Teitelman on February 27, 1983 2:52 pm
DIRECTORY
RTBasic USING [TV, Type]
;
AMExtras: CEDAR DEFINITIONS
= BEGIN OPEN RTBasic;
IsARefType: PROC [type: Type] RETURNS[BOOL];
returns TRUE if tv describes a ref, i.e. if its type class is ref, atom, or rope.
IsOfTypeT: PROC [tv: TV, T: Type] RETURNS[BOOL];
returns TRUE if tv describes an element of or equivalent to type T. Handles the case where tv describes a REF ANY and T is an atom, rope, or ref to a specific type
Cons: PROC[element: TV -- of type T--, list: TV -- LIST OF T --] RETURNS[TV -- LIST OF T --];
element is a TV which describes a value of type T (T may be a ref type), list a TV which describes a value of type LIST OF T. Cons returns a TV which describes a value of type LIST OF T consisting of consing element onto the front of list. For example, if element describes the INT 3, and list describes the value of LIST[2, 1], Cons[element, list] will describe LIST[3, 2, 1].
Note that list cannot be identically NIL; it must be a TV which describes a value of type LIST OF T, whose value may be NIL. To construct such a tv given the type LIST OF T, use the procedure List described below.
List: PROC[listType: Type -- LIST OF T -- , first, second, third, fourth: TVNIL] RETURNS[TV];
listType corresponds to a type LIST OF T, and first, second, third, and fourth are TV's which describe values of type T. List returns a TV which describes a value of type LIST OF T consisting of a list of the non-NIL tvs. For example, if T is LIST OF INT, and x describes 1, y describes 2, and z describes 3, then List[T, x, y] returns a tv which the value of LIST[1, 2, 3].
Note that List[listType] returns a TV for an empty list of type listType.
END. -- AMExtras