* New version of IRM New version of the IRM, updated to Medley. * moved to docs/medley-irm as discussed
157 lines
69 KiB
Plaintext
157 lines
69 KiB
Plaintext
INTERLISP-D REFERENCE MANUAL
|
||
RECORDS AND DATA STRUCTURES
|
||
"8"RECORDS AND DATA STRUCTURES
|
||
3
|
||
|
||
|
||
Hiding the details of your code makes it more readable, and lets you program more efficiently. Data structures are a good example: You're better off if you can say ªFetch me the SPEED field from this AIRPLANEº rather than having to say (CAR (CDDDR (CADR AIRPLANE))). You can declare data structures used by your programs, then work with field names rather than access details. Using the declarations, Medley performs the access/storage operations you request. If you change a data structure's declaration, your programs automatically adjust.
|
||
You describe the format of a data structure (record) by making a ªrecord declarationº (see the Record Declarations section below). The record declaration is a description of the record, associating names with its various parts, or ªfieldsº. For example, the record declaration
|
||
(RECORD MSG (FROM TO TEXT))
|
||
describes a data structure called MSG, that has three fields: FROM, TO, and TEXT. You can refer to these fields by name, to get their values or to store new values into them, by using FETCH and REPLACE:
|
||
(fetch (MSG FROM)of MYMSG)
|
||
(replace (MSG TO) of MYMSG with ªJohn Doeº)
|
||
You create new MSGs with CREATE:
|
||
(SETQ MYMSG (create MSG))
|
||
and TYPE? tells you whether some object is a MSG:
|
||
(IF (TYPE? MSG THIS-THING) then (SEND-MSG THIS-THING))
|
||
So far we've said nothing about how your MSG is representedÿÿ |