From what I read, to detect eof in lisp when using read, one
uses the keyword parameters like eof-error-p and eof-value.
Thing is, I can't get these to work. I'm using CMUCL and
tried Harlequin FreeLisp and I get errors like the following:
(read t :eof-error-p nil) => EOF is treated as an error anyway
(read t :eof-error-p nil :eof-value 'done) => get an error about
too many params.
Would someone be kind enough to provide me with an example
of how to use this feature properly?
Thanks.
--
Ahmed
My email address is invalid. To reply, mail to punkrock at
cs dot uh dot edu.
| Would someone be kind enough to provide me with an example of how to use
| this feature properly?
try (KERNEL:%FUNCTION-ARGLIST #'READ) in CMUCL, check the HyperSpec or
look more close in whatever textbook you're using.
note that even if EOF-ERROR-P is false, an error is caused if RECURSIVE-P
is true, i.e., the EOF-VALUE argument is returned only if the end of file
occurs at top-level.
if you want to be certain that you do not detect end of file prematurely,
pass a guaranteed unique value as EOF-VALUE, such as a fresh, uninterned
symbol, a fresh cons cell, or somesuch.
#:Erik
--
God grant me serenity to accept the code I cannot change,
courage to change the code I can, and wisdom to know the difference.
> Hi,
>
> From what I read, to detect eof in lisp when using read, one
> uses the keyword parameters like eof-error-p and eof-value.
> Thing is, I can't get these to work. I'm using CMUCL and
> tried Harlequin FreeLisp and I get errors like the following:
>
> (read t :eof-error-p nil) => EOF is treated as an error anyway
>
> (read t :eof-error-p nil :eof-value 'done) => get an error about
> too many params.
>
These are not keyword parameters - but optional parameters.
READ &optional input-stream eof-error-p eof-value recursivep
[Function]
reads the printed representation of a single object from input-stream,
builds a corresponding object, and returns the object.
Use:
(read t nil 'done)
--
http://www.lavielle.com/~joswig/
I saw references to parameter names in CLTL2 and I just assumed
that the parameters were being explicitly mentioned for a reason,
and one logical blunder led to another and the next thing I knew
I was trying to use them as keywords.
I apologize for wasting bandwidth, when I should have been
paying more attention to the document.
Thank you,
Ahmed
My email address is invalid due to spam. To email, send to punkrock