Subject: [clisp-list] Problems with read-line

From: Leonardo Bitsch <[email-masked]>
Date: Wed, 31 Jan 2001 15:33:16 -0200 (BRST)

I have this code to read from a file some algorithm that came from a HTML
text area. I want that this code read (and compile) the file until the end
of file and not only the line (with "read-line"). How can I do this?
Thanks,

(setf *error-output*    (open "erro"  :direction :output))
(setf *standard-output* (open "saida" :direction :output))

(setf ?arq (open "input.lsp"))
(handler-case
           (loop
                (eval (read-from-string (read-line ?arq)))
           )

(stream-error () (read-from-string "fim_do_arquivo")))

(cerror  "Nenhum erro foi encontrado no c&oacute;digo fornecido!")

(close *error-output*)
(close *standard-output*)

---

From: Bruno Haible <[email-masked]>
Date: Wed, 31 Jan 2001 18:54:38 +0100 (CET)

Leonardo Bitsch writes:
> I want that this code read (and compile) the file until the end

One possibility is that you write a function 'read-contents' which
reads the contents of a stream until EOF, and returns it as a string.

Another possibility, if the stream may contain multiple Lisp forms, is
to call  (load stream). 'load' also accepts streams, not only filenames.

Bruno