[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

:Structure-Print and *print-level*

Many thanks to Scott for illuminating this issue.  The idea I had had
in mind was that the defstruct printing function would look something

(defun astronaut-print-fn (obj s depth)
   (format s "[***>>> ASTRONAUT!  Name: ")
   (write (astro-name obj) :stream s :level (- *print-level* depth))
   (format s " <<<***]"))

However, this is not quite the right thing if the originally specified
:level argument had not defaulted to the value of *print-level*.

One suggestion is to redefine the third argument to a structure print
function to be "depth remaining", to be compared against zero.  Then
one would write

(defun astronaut-print-fn (obj s depth)
   (format s "[***>>> ASTRONAUT!  Name: ")
   (write (astro-name obj) :stream s :level (- depth 1))
   (format s " <<<***]"))

In retrospect, I think it was not defined this way because in MacLISP
I had frequently found it very convenient, when faced with a large
(possible infinite) printout, to do a break, set PRINLEVEL to some
finite value, and then resume, whereupon the printout would quickly
cut itself off, allowing computation to resume.  The second treatment
shown above would not respond to dynamic changes in *PRINT-LEVEL*.
Is this important?