[Ecls-list] read-char eof issue?

Raymond Toy toy.raymond at gmail.com
Sat Aug 23 17:22:44 UTC 2008


Consider the follow snip of code (extracted from a larger piece of code 
from f2cl):
(defun foo ()
  (let ((*inp* (make-string-input-stream "  ")))
    (labels
    ((my-char= (char1 char2)
       (and (characterp char1)
        (characterp char2)
        (char= char1 char2)))
     (skip-spaces ()
       (format t "skip-spaces~%")
       (do ((nxt (peek-char nil *inp* nil 'eof)
             (peek-char nil *inp* nil 'eof)))
           ((not (my-char= nxt #\Space))
        (format t "skip-spaces done: ~S~%" nxt)
        nxt)
         (read-char *inp* nil 'eof t))))
      (format t "char ~S~%" (skip-spaces))
      (format t "next ~S~%" (read-char *inp* nil 'eof t)))))

When I compile and run this, I get an error from the final read-char.  
If the T arg to read-char is removed, then there is no error.

I don't understand the recursive-p arg very well, and I think in this 
example it should probably not be T.

However, both cmucl and clisp don't complain for this example.

Ray




More information about the ecl-devel mailing list