On Sat, 10 Dec 2011, Raymond Wiker wrote:
> On Dec 10, 2011, at 20:02 , Tamas Papp wrote:
> > On Sat, 10 Dec 2011, Raymond Wiker wrote:
> >> On Dec 10, 2011, at 16:10 , Tamas Papp wrote:
> >>> I thought about that, but I got this error even when I regenerated the
> >>> instances according to the new layout. Of course, I don't know how
> >>> deeply SBCL inlines the layout, so it could happen that I forgot to
> >>> recompile something, but I did an asdf reload and still got the error
> >>> message.
> >> Quote from The Hyperspec:
> >> "The consequences of redefining a defstruct structure are undefined."
> >> Maybe this has been mentioned already, and maybe SBCL makes more of
> >> an effort to support structure redefinition, but still...
> > Sure, the standard basically says that I should not do it, and should
> > not complain if I do and bad things happen. Which is a reasonable
> > attitude I guess.
> > Is there a way I could have quick-dirty print-object methods defined
> > for classes? Does not need to be readable, but it is so nice to punt
> > on the nice printed representations of structures when I am trace'ing.
> > Otherwise, I would be much better off with classes. Maybe someone
> > already has a mixin class or something similar in a library that I
> > have missed.
> > Tamas
> Maybe something like this (which uses a bit of MOP, namely class-slots and slot-definition-name):
> (defmethod print-object ((object my-base-class-or-mixin) stream)
> (print-unreadable-object (object stream :type t :identity t)
> (dolist (slot-def (class-slots (class-of object)))
> (let ((slot-name (slot-definition-name slot-def)))
> (format stream "~&~a: ~a~%" slot-name (slot-value object slot-name))))))
Thanks, I also found fare-mop:simple-print-object-mixin which does
something like this.