defstruct print function

steve gonedes <[email protected]>
Newsgroups gmane.lisp.steel-bank.general
Message-ID <[email protected]>
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.


; SLIME 2.26.1
CL-USER> (defun print-jtms (jtms stream ignore)
   (declare (ignore ignore))
   (format stream "#<JTMS: ~A>" (jtms-title jtms)))

; in: DEFUN PRINT-JTMS
;     (JTMS-TITLE JTMS)
;
; caught STYLE-WARNING:
;   undefined function: COMMON-LISP-USER::JTMS-TITLE
;
; compilation unit finished
;   Undefined function:
;     JTMS-TITLE
;   caught 1 STYLE-WARNING condition
PRINT-JTMS
CL-USER>
; No value
CL-USER> (defstruct (jtms (:copier nil) (:print-function print-jtms))

   (title nil)
   (node-counter 0)             ;; unique namer for nodes.
   (just-counter 0)             ;; unique namer for justifications.
   (nodes nil)                  ;; list of all tms nodes.
   (justs nil)                  ;; list of all justifications
   (debugging nil)              ;; debugging flag
   (contradictions nil)         ;; list of contradiction nodes.
   (assumptions nil)            ;; list of assumption nodes.
   (checking-contradictions T)  ;; For external systems
   (node-string nil)
   (contradiction-handler nil)
   (enqueue-procedure nil))

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.
JTMS
CL-USER> (create-jtms)
; in: CREATE-JTMS
;     (CREATE-JTMS)
;
; caught STYLE-WARNING:
;   undefined function: COMMON-LISP-USER::CREATE-JTMS
;
; compilation unit finished
;   Undefined function:
;     CREATE-JTMS
;   caught 1 STYLE-WARNING condition
; Evaluation aborted on #<UNDEFINED-FUNCTION CREATE-JTMS {10070C7903}>.
CL-USER> (make-jtms)
#<JTMS: NIL>
CL-USER> (defstruct (jtms (:copier nil) (:print-function print-jtms))

   (title nil)
   (node-counter 0)             ;; unique namer for nodes.
   (just-counter 0)             ;; unique namer for justifications.
   (nodes nil)                  ;; list of all tms nodes.
   (justs nil)                  ;; list of all justifications
   (debugging nil)              ;; debugging flag
   (contradictions nil)         ;; list of contradiction nodes.
   (assumptions nil)            ;; list of assumption nodes.
   (checking-contradictions T)  ;; For external systems
   (node-string nil)
   (contradiction-handler nil)
   (enqueue-procedure nil))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.