From: Christophe R. <cs...@ca...> - 2010-04-14 11:27:36
|
David Creelman <cre...@gm...> writes: > The example code is copied from the CLHS. Just so you know, examples from the CLHS are not normative, and there are often points in them that are debatable or outright wrong with reference to the actual text of the standard. > The following lines and it's output are reproduced below > > * (flet ((test (x) > (let ((*print-pretty* t)) > (print x) > (format t "~%~S " x) > (terpri) (princ x) (princ " ") > (format t "~%~A " x)))) > (test '#'(lambda () (list "a" #'c #'d)))) > > #'(LAMBDA () (LIST "a" #'C #'D)) > #'(LAMBDA () (LIST "a" #'C #'D)) > #'(LAMBDA () (LIST a #'C #'D)) > #'(LAMBDA () (LIST a #'C #'D)) > NIL > > I was expecting to get something like :- >>> #'(LAMBDA () >>> (LIST "a" #'C #'D)) >>> #'(LAMBDA () >>> (LIST "a" #'C #'D)) >>> #'(LAMBDA () >>> (LIST a b 'C #'D)) >>> #'(LAMBDA () >>> (LIST a b 'C #'D)) > => NIL > > Have I done something wrong here? I think you need to be more precise in your question. I don't see any way that the pretty printer can insert some `b's into the printed text, at least not without some more work -- nor to turn (FUNCTION C) into 'C. Is your main issue the line breaks? Pretty printing of `code' probably puts in mostly discretionary line breaks rather than mandatory ones. You can override any individual operator's pretty printing with your own dispatch table entry if you have particular needs. (For very short anonymous function bodies like yours above, I think it's clear that no linebreak is needed -- I don't think you'd put one in code like (let ((fun (lambda () (list "a" #'c #'d)))) (funcall fun)) Best, Christophe |