From: ··········@bbs.ee.ncu.edu.tw
Subject: What's wrong with gcl-2.6.6 ?
Date: 
Message-ID: <1130151613.992400.30770@g44g2000cwa.googlegroups.com>
The follwoing codes are from "Practical Common Lisp" :
(defvar *db* nil)

(defun make-cd (title artist rating ripped)
(list :title title :artist artist :rating rating :ripped ripped))

(defun add-record (cd) (push cd *db*))

(defun dump-db ()
(format t "~{~{~a:~10t~a~%~}~%~}" *db*))

(defun prompt-read (prompt)
(format *query-io* "~a: " prompt)
(force-output *query-io*)
(read-line *query-io*))

(defun prompt-for-cd ()
(make-cd
(prompt-read "Title")
(prompt-read "Artist")
(or (parse-integer (prompt-read "Rating") :junk-allowed t) 0)
(y-or-n-p "Ripped [y/n]: ")))

under gcl-2.6.6 , the function call of (prompt-for-cd) gets the
following responses:
dbl:>>
(prompt-for-cd)
Title: Artist: 1 2
^^^^^^^^^^^^^
Rating: 3

Ripped [y/n]: (Y or N) y

(:TITLE "" :ARTIST "1 2" :R  ...

The words "Title:" and  "Artist:" appear in the same line ,
that's an obvious error.
   The same lisp codes run on CLISP-2.34 and return as below:
[7]> (prompt-for-cd)
Title: 1
Artist: 2
Rating: 3
Ripped [y/n]: (y/n) 4
Please answer with y or n : y
(:TITLE "1" :ARTIST "2" :RATING 3 :RIPPED T)

Can anyone tell me what error is in GNU common lisp ?
From: Camm Maguire
Subject: Re: What's wrong with gcl-2.6.6 ?
Date: 
Message-ID: <54ll0gbcc8.fsf@intech19.enhanced.com>
Greetings, and thanks for this report!

You've found a bug in our reader apparently.  The newline following
the invocation of (prompt-for-cd) is not read from the stream when
'(prompt-for-cd) is read, and is hence left on the stream for reading
when prompt-for-cd is evaluated.  

Its an easy fix provided one knows what the right thing to do is.
Should readers always swallow trailing whitespace when invoked at
top-level and without being invoked via read-preserving-whitespace?

If you want to test more of this, just add a (read-line) before the
(make-cd ...) in the prompt-for-cd function definition for now.

Take care,

··········@bbs.ee.ncu.edu.tw writes:

> The follwoing codes are from "Practical Common Lisp" :
> (defvar *db* nil)
> 
> (defun make-cd (title artist rating ripped)
> (list :title title :artist artist :rating rating :ripped ripped))
> 
> (defun add-record (cd) (push cd *db*))
> 
> (defun dump-db ()
> (format t "~{~{~a:~10t~a~%~}~%~}" *db*))
> 
> (defun prompt-read (prompt)
> (format *query-io* "~a: " prompt)
> (force-output *query-io*)
> (read-line *query-io*))
> 
> (defun prompt-for-cd ()
> (make-cd
> (prompt-read "Title")
> (prompt-read "Artist")
> (or (parse-integer (prompt-read "Rating") :junk-allowed t) 0)
> (y-or-n-p "Ripped [y/n]: ")))
> 
> under gcl-2.6.6 , the function call of (prompt-for-cd) gets the
> following responses:
> dbl:>>
> (prompt-for-cd)
> Title: Artist: 1 2
> ^^^^^^^^^^^^^
> Rating: 3
> 
> Ripped [y/n]: (Y or N) y
> 
> (:TITLE "" :ARTIST "1 2" :R  ...
> 
> The words "Title:" and  "Artist:" appear in the same line ,
> that's an obvious error.
>    The same lisp codes run on CLISP-2.34 and return as below:
> [7]> (prompt-for-cd)
> Title: 1
> Artist: 2
> Rating: 3
> Ripped [y/n]: (y/n) 4
> Please answer with y or n : y
> (:TITLE "1" :ARTIST "2" :RATING 3 :RIPPED T)
> 
> Can anyone tell me what error is in GNU common lisp ?
> 

-- 
Camm Maguire			     			····@enhanced.com
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah