Re: defstruct print function
| Newsgroups | gmane.lisp.steel-bank.general |
|---|---|
| Message-ID | <ZrfocDKnUHzv4ni2@anomaly> |
On 2024-08-10 at 18:03:49 -0400, steve gonedes <[email protected]> wrote: > I am having some trouble using the print-function with defstruct. I cannot > remember how to handle the warnings. if one could point me to the manual. > any ideas - run into this problem often. I'm no expert, but I notice two things. > ; SLIME 2.26.1 > CL-USER> (defun print-jtms (jtms stream ignore) > (declare (ignore ignore)) > (format stream "#<JTMS: ~A>" (jtms-title jtms))) Have a look at PRINT-UNREADABLE-OBJECT, which takes care of some of what you're doing yourself for you. This is totally separate from DEFSTRUCT and PRINT-FUNCTION. > STYLE-WARNING: > Previously compiled call to COMMON-LISP-USER::JTMS-TITLE could not be > inlined because the structure definition for COMMON-LISP-USER::JTMS was not > yet seen. To avoid this warning, DEFSTRUCT should precede references to the > affected > functions, or they must be declared locally notinline at each call site. Make sure you define your structures first, so that your print functions have full knowledge of the structures and the accessors. You're on your own when it comes to changing your structure definitions and making sure that all the supporting functions recompiled (I keep restarting my REPL over and over until my structures stabilize). HTH