[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
:Structure-Print and *print-level*
The current depth in printing is an argument to defstruct
structure printing functions. If the print function calls print
recursively, should print start over again at zero, or do something
else? If the depth in printing is preserved across the call to the
structure-print function, should it be the same in the recursive call,
or one greater?
I was hoping that someone who had thought a lot about printing issues
would jump up and take a crack at this, but since nobody has, I'll give
it a try. I haven't dealt with printer issues much, so if somebody sees
a deep bogosity in my analsysis, please step forward.
When built-in data structures are being printed, each level of recursion
into sub-structure bumps some hidden counter by 1, and when this value
exceeds *print-level*, the printing becomes terse. This facility is not
accessible to the user in any way that I can see -- either there is some
special internal call to print that takes a current-depth argument or
print looks at some undocumented special to get this sort of behavior.
The user-accessible Print function, as it is currently defined, would
seem always to set the print-depth back to zero when called explicitly.
At least, in my quick scan of the manual I didn't see any way of doing
The obvious intent in structure printing is that we want users to be
able to write print functions that mimic the behavior of built-in print
methods -- in this way, we hope to make the user-defined structures act
like built-in data types. So the right thing to do would be to let
these print functions access the current depth, and let them call the
print functions, explicitly passing on the depth argument, usually
incremented by one.
Well, I think we blew it, since user-code has no way of calling Print
and friends with an explicit depth argument, incremented or not. It
would be possible to add some magic kludge whereby Print and friends
realize that they are being called recursively within a structure-print
routine and somehow figure out what the current depth ought to be. That
stikes me as being very confusing and dangerous. I would suggest that
Print and friends continue to reset the depth to zero when called
explicitly, but that sometime soon we should provide a way of slipping
some non-zero current depth to these functions explicitly. This should
probably be done with an additional optional or keyword arg to the
existing print functions (or maybe just to Write).