4.4 The Inspector
;; Define a Lisp structure, struct-1, with constructor ;; make-struct-1 and slots a, b, and c. Slot c is initialized ;; to 0. > (defstruct (struct-1) a b (c 0)) STRUCT-1;; Define a Lisp structure, struct-2, with constructor ;; make-struct-2 and slots x, y, and z. > (defstruct (struct-2) x y z) STRUCT-2 > (setq aa (make-struct-1)) #S(STRUCT-1 A NIL B NIL C 0)
;; Calling the Inspector on the structure aa displays the ;; structure's components with the slots numbered for reference. > (inspect aa) #<Structure STRUCT-1 3D9293> [0: A] NIL [1: B] NIL [2: C] 0
>> 44 44 is out of range as an index for this item.
>> 2 0
>> :u ; Pop to previous level. #<Structure STRUCT-1 3D9293> [0: A] NIL [1: B] NIL [2: C] 0
>> (setq bb (make-struct-2 :x 11 :y (list 22 33))) ; This input is #<Structure STRUCT-2 3DC3A3> ; evaluated and then inspected [0: X] 11 [1: Y] (22 33) [2: Z] NIL
>> 1 #<List 3DCC99> [0] 22 [1] 33
>> :q (22 33)
Generated with Harlequin WebMaker