[Next] [Prev] [_____] [Left] [Up] [Index] [Root]
Access and Modification Functions

Access and Modification Functions

Fields of records may be inspected, assigned and deleted at any time.

Format(r) : Rec -> RecFormat
The format of record r.
Names(F) : RecFormat -> [ MonStgElt ]
The fieldnames of the record format F returned as a sequence of strings.
Names(r) : Rec -> [ MonStgElt ]
The fieldnames of record r returned as a sequence of strings.
r`fieldname : Rec, Fieldname -> Elt
Return the field of record r with this fieldname. The format of r must include this fieldname, and the field must be assigned in r.
r`fieldname := expression;
Reassign the given field of r to be the value of the expression. The format of r must include this fieldname, and the expression's value must satisfy (directly or by coercion) any restriction on the field.
delete r`fieldname : Rec, Fieldname -> Nil
(Statement.) Delete the current value of the given field of record r.
assigned r`fieldname : Rec, Fieldname -> BoolElt
Returns true if and only if the given field of record r currently contains a value.
r``s : Rec, String -> Elt
Given an expression s that evaluates to a string, return the field of record r with the fieldname corresponding to this string. The format of r must include this fieldname, and the field must be assigned in r.

This syntax may be used anywhere that r``fieldname may be used, including in left hand side assignment, assigned and delete.


Example Rec_RecordAccess (H7E3)

> V4 := u`misc;          
> print assigned r`seq;  
false
> r`seq := Append(t`seq, t`n); print assigned r`seq; 
true
> print r;
rec<RF | seq := [ 4.7, 1.9, 17 ]>
> print t``(s`misc);

>> print t``(s`misc); ^ Runtime error in `: Field 'adsifaj' does not exist in this record > delete u``("m" cat "isc"); print u; rec<RF | >

[Next] [Prev] [_____] [Left] [Up] [Index] [Root]