From: Adam Warner <lists@co...>  20041118 10:13:31

Hi Peter Hÿffffe4fliger, > (defun mysquare () > (format t "Please type in a number: ") > (let ((x (read))) > (format t "The number ~S squared is ~S.~%" x (* > x x)))) > > It should produce: > >> (mysquare) > Please type in a number: 7 > The number 7 squared is 49. > NIL > > but intead produces: > > CLUSER(2): (mysquare) > 7 > Please type in a number: The number 7 squared is 49. > NIL > CLUSER(3): > > in abcl. All works well if I put a newline at the end > of the of the first string: > > (format t "Please type in a number: ~%") > > CLUSER(4): (mysquare) > Please type in a number: > 7 > The number 7 squared is 49. > NIL > CLUSER(5): > > But I don't really want a line break there, and as I > take from Touretzky's book (and also from Paul > Graham's `ANSI Common Lisp' which should describe the > standard), it should work without the newline as well. > > Is that a bug or am I misunderstanding something here? While not being Peter I still enjoyed your introduction. The problem above is that you need to flush the output since it didn't happen automatically due to a newline. It's not a bug. (defun mysquare () (format t "Please type in a number: ") (forceoutput) (let ((x (read))) (format t "The number ~S squared is ~S.~%" x (* x x)))) Note that unless you bind *READEVAL* to NIL you can evaluate code within READ which has security implications. Please type in a number: #.(+ 1 2) The number 3 squared is 9. That could just have easily been a function call to DELETEFILE. (defun mysquare () (format t "Please type in a number: ") (forceoutput) (let* ((*readeval* nil) (x (read))) (format t "The number ~S squared is ~S.~%" x (* x x)))) (mysquare) Please type in a number: #.(+ 1 2) Debugger invoked on condition of type READERERROR: Can't read #. when *READEVAL* is NIL. Regards, Adam 