[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
File I/O
There's not a separate function. Most reader functions (eg, READ and READ-LINE)
take an eof-p argument that says whether to signal an error if you read past
the end of a file. The default is T, but if you specify NIL then you can specify
a value to be returned when you have read past the end of file. Here are some
examples:
(DEFUN SHOW-FILE (FILE)
(WITH-OPEN-FILE (STREAM FILE)
(DO ((LINE (READ-LINE STREAM NIL NIL) (READ-LINE STREAM NIL NIL)))
((NOT LINE))
(WRITE-LINE LINE))))
(DEFUN GET-LISP-FORMS-FROM-FILE (FILE)
(WITH-OPEN-FILE (STREAM FILE)
(LET ((UNIQUE (LIST NIL)))
(DO ((FORM (READ STREAM NIL UNIQUE) (READ STREAM NIL UNIQUE))
(RESULT '() (CONS FORM RESULT)))
((EQ FORM UNIQUE) (NREVERSE RESULT))))))
By the way, the Common-Lisp list is -very- large (probably many hundreds of
recipients) and probably overkill for this kind of simple `how to' question.
Contacting your vendor or individually contacting just about any one of the
people you see contributing to this list would probably have gotten you the
same answer at lower cost to the community.
- References:
- File I/O
- From: David Greene <dg1v+@andrew.cmu.edu>