From ... From: Erik Naggum Subject: Re: constants in functions Date: 1998/03/21 Message-ID: <3099464838956972@naggum.no>#1/1 X-Deja-AN: 336225216 References: mail-copies-to: never Organization: Naggum Software; +47 8800 8879; http://www.naggum.no Newsgroups: comp.lang.lisp * Sam Steingold | (defun note-add (obj new) | (setf (slot-value 'note obj) | (concatenate 'string (slot-value 'note obj) (string #\newline) new))) | | I don't want each call to note-add to re-compute (string #\newline). (defconstant newline-string (string #\newline)) depending on how often I would print the notes and how often I would add notes, I think I would have used a (reversed) list of note lines that I would then print out with something like this: (format "~{~&~A~}" (reverse (slot-value 'note obj))) note that the printer could put this string back into place once it had computed it, and the first note to be printed could very well by a multi-line note: (defun print-note (object &optional (stream *standard-output*)) (let ((formatted-note (format nil "~{~A~^~%~}" (nreverse (slot-value 'note object))))) (setf (slot-value 'note object) (list formatted-note)) (write formatted-note :stream stream :escape nil))) (defun note-add (object note) (push note (slot-value 'note object))) #:Erik -- religious cult update in light of new scientific discoveries: "when we cannot go to the comet, the comet must come to us."