Outdated egg!
This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
describe-coops
Display textual descriptions of built-in objects, user-created records, and coops objects.
Overview
describe-coops provides the same API as describe but additionally supports 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.
Usage
(use describe-coops)
There's no need to load describe, as this egg loads describe itself and exports a compatible API. Loading describe after describe-coops will wipe out the REPL shortcuts.
REPL
The REPL shortcuts -- ,d and friends -- provided by the describe egg are extended to support coops objects.
API
[procedure] (describe obj #!optional out)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.
[procedure] (describe-object obj out)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)[parameter] (describe-sequence-limit n)
[procedure] (set-describer! tag proc)
[procedure] (dump obj #!optional offset length out)
[procedure] (hexdump bv start end ref out)
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.
Version history
- 0.1
- Initial release
Author
Jim Ursetto, Ursetto Consulting, Inc.
Some code was taken from Kon Lovett's coops-utils egg.
License
MIT.