Display textual descriptions of built-in objects, user-created records, and coops objects.
The only API difference is the addition of a describe-object generic procedure, with a useful default implementation for coops classes and objects. If coops-primitive-objects is loaded, you can specialize on primitive objects as well.
The REPL shortcuts -- ,d and friends -- provided by the describe egg are extended to support coops objects.
- describe obj #!optional outprocedure
Prints a textual description of OBJ to output port OUT, which defaults to (current-output-port). For coops objects, this dispatches to describe-object; otherwise it calls describe from the describe egg.
Note that this is not a generic procedure.
- 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)
- describe-sequence-limit nparameter
- set-describer! tag procprocedure
- dump obj #!optional offset length outprocedure
- hexdump bv start end ref outprocedure
Same as their describe egg equivalents. They are exported for convenience, so (use describe) is not required when using this egg.
It's not currently possible to dump a coops object.
- Initial release
Some code was taken from Kon Lovett's coops-utils egg.