Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

eof in Common Lisp

397 views
Skip to first unread message

wan...@exploited.barmy.army

unread,
Mar 7, 1998, 3:00:00 AM3/7/98
to

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.


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.


Erik Naggum

unread,
Mar 7, 1998, 3:00:00 AM3/7/98
to

* wan...@exploited.barmy.army

| From what I read, to detect eof in lisp when using read, one uses the
| keyword parameters like eof-error-p and eof-value.
^^^^^^^
where did you read that?

| 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.

Rainer Joswig

unread,
Mar 7, 1998, 3:00:00 AM3/7/98
to

In article <6dsg64$mg8$1...@Masala.CC.UH.EDU>, wan...@exploited.barmy.army wrote:

> 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/


wan...@exploited.barmy.army

unread,
Mar 8, 1998, 3:00:00 AM3/8/98
to

Thanks for the assistance, and sorry for my silly blunder.

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

0 new messages