From: ······@exploited.barmy.army
Subject: eof in Common Lisp
Date: 
Message-ID: <6dsg64$mg8$1@Masala.CC.UH.EDU>
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.

From: Erik Naggum
Subject: Re: eof in Common Lisp
Date: 
Message-ID: <3098298853739382@naggum.no>
* ······@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.
From: ······@exploited.barmy.army
Subject: Re: eof in Common Lisp
Date: 
Message-ID: <6dukjt$t06$1@Masala.CC.UH.EDU>
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
at cs dot uh dot edu.
From: Rainer Joswig
Subject: Re: eof in Common Lisp
Date: 
Message-ID: <joswig-0703982328550001@194.163.195.66>
In article <············@Masala.CC.UH.EDU>, ······@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/