I am having some trouble with Richard Waters' XP pretty printer
functions. I am getting a stream error whenever I attempt a
recursive call from within a pprint-logical-block. When I take
out the recursive call, it works fine; however, the recursion
makes it crash immediately. Any hints, suggestions or blind,
half-assed guesses woud be appreciated.
Please e-mail to ······@comm.mot.com
Here's the relevant code:
(defun test$print (term)
:
:
(t
(cond
((or (operator$is_standard hd) (not *fancy-print*))
(let ((prv nil))
(dolist (i (operator$name hd))
(when (and prv (print$need_space prv i)) (princ " "))
(setq prv i)
(princ i)))
(let ((subs (term$subterms term)))
(xp::pprint-logical-block (nil subs :prefix "(" :suffix ")")
(setq flg nil)
(loop (if flg (princ ",") (setq flg t))
Recursive Call ---> (test$print (xp::pprint-pop))
(xp::pprint-exit-if-list-exhausted))))
Here's a transcript of my lisp session:
Top level.
>(step (test$print x))
Type ? and a newline for help.
(test$print x)
x
= ((# nil . 1) (# #))
:
: Just a LET statement
:
(cond (# # ...) ...)
:
: Lots of failed COND checks
:
t
(cond (# # ...) ...)
(or (operator$is_standard hd) ...)
(operator$is_standard hd)
hd
= #S(operator name ...)
= nil
(not *fancy-print*)
*fancy-print*
= nil
= t
= t
(let (#) ...)
nil
(dolist (i #) ...)
(operator$name hd)
(operator-name hd)
hd
= #S(operator name ...)
= ("PROGRAM")
= ("PROGRAM")
(when (and prv ...) ...)
(and prv ...)
prv
= nil
= nil
= nil
(setq prv ...)
i
= "PROGRAM"
= "PROGRAM"
(princ i)
i
= "PROGRAM"
PROGRAM = "PROGRAM"
nil
= nil
= nil
(let (#) ...)
(term$subterms term)
(cdr term)
term
= ((# nil . 1) (# #))
= ((# #))
= ((# #))
(xp::maybe-initiate-xp-printing #'(lambda # ...) ...)
#'(lambda (*standard-output*) ...)
= (lambda-closure (# # ...) ...)
(xp::decode-stream-arg *standard-output*)
*standard-output*
= #<synonym stream to *terminal-io*>
= #<synonym stream to *terminal-io*>
Error: #<XP stream outputting to #<synonym stream to *TERMINAL-IO*>
buffer= "" ...> is not of type STREAM.
Fast links are on: do (use-fast-links nil) for debugging
Error signalled by SYSTEM::STEPPER.
Broken at SYSTEM::STEPPER. Type :H for Help.
>>
Top level.
>