[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Printing Objects
- To: Moon@STONY-BROOK.SCRC.Symbolics.COM
- Subject: Re: Printing Objects
- From: Masinter.pa@Xerox.COM
- Date: 6 May 87 22:01 PDT
- Cc: common-lisp-object-system@SAIL.STANFORD.EDU
- In-reply-to: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>'s message of Wed, 6 May 87 23:22 EDT
Of the alternatives:
a) All objects print out as #S, if you want different behavior, you
b) By default, objects can't print themselves, and you have to provide a
print function or else mixin a standard class
Consider three cases:
1) object wants to print out as #S...
2) object cannot be printed really -- it doesn't make sense to "read" it
3) object wants to be printed in a special way
Case 1: a is preferable, since what you want to do is already the
Case 2: b is only marginally better. In alternative a, you have to
supply an error-if-you-print-me method or else you will get printing
when you shouldn't really --if your erroneously print something and
try to read it back in, alternative b gives you an error at print time,
while alternative a gives you an error later on in your program.
Case 3: it makes no difference, since you're supplying a print method.
I think Case 1 is the most common in most of the program's I've seen