[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
printing closures
I've assigned a problem to my AI Programming class using
continuations, and it would sure help them if there was some way to
print a closure (i.e. the result of calling (function (lambda ...)))
so that you can see the lambda expression and the bindings, and so
that if the value of a binding is a closure it is recursively printed
in this nice form. I had something hacked up for older versions of
Allegro that depended on the closures being represented as s-exprs,
but of course that won't work anymore. If I even had access functions
to get at the fields of a closure I could do this.
The only current solution is to use the inspector, but that's a LOT more
cumbersome than a simple function to pretty print the closure.
One possible hack would be to use the function top-level:do-command
to call the inspector from a function, but for this to be useful it
qould be necessary to somehow turn off or divert the output that the
inspector sends tothe terminal. Rebinding the obvious globals
(e.g. *terminal-io* and *debug-io*) to /dev/null does not seem to
do the trick, nor does changing top-level:*print*.
Does anyone have any advice, code, hacks, etc, to help me?
Thanks.