- describe-object obj outprocedure
Generic procedure specialized on OBJ, responsible for printing the textual description of OBJ. describe calls this under the hood.
#;> (define-class <point> () (x y z))
#;> (describe <point>) coops standard-class <point> class precedence list: (<standard-object>) slots: (x y z)
#;> (describe (make <point> 'x 1 'y 2 'z 3)) coops instance of class <point>: x : 1 y : 2 z : 3
#;> (define-method (describe-object (obj <point>) out) (fprintf out "<point> object with coordinates (~A, ~A, ~A)~%" (slot-value obj 'x) (slot-value obj 'y) (slot-value obj 'z)))
#;> (describe (make <point> 'x 1 'y 2 'z 3)) <point> object with coordinates (1, 2, 3)
If coops-primitive-objects is loaded, you can specialize on primitive objects such as fixnums; the default implementation prints both the object's class and the describe egg's description. For example:
#;> (describe 3) exact integer 3 (#x3 #o3 #b11 #\x3) #;> (use coops-primitive-objects) #;> (describe 3) coops instance of primitive class <fixnum> exact integer 3 (#x3 #o3 #b11 #\x3)