Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Newbie asking for help
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Christopher Browne  
View profile  
 More options Jun 23 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: cbbro...@news.hex.net (Christopher Browne)
Date: 2000/06/23
Subject: Re: Newbie asking for help
Centuries ago, Nostradamus foresaw a time when Jochen Schmidt would say:

>The Glauber wrote:
>> ;; count number of lines in file key.html
>> (with-open-file (ifile "key.html" :direction :input)
>>                 (setf nlines 0)
>>                 (loop
>>                   (if (read-line ifile nil)
>>                     (setf nlines (+ 1 nlines))
>>                     (return nlines))))

>> It doesn't work (it just hangs, so i think it's stuck in the loop). I
>> thought it would read lines until the end of the file, when the read-
>> line would return nil, and that would trigger the second form inside
>> the if (a return, to get out of the loop).

>> I'm sorry for posting something so stupid, but why doesn't this work?

>It works for me in cmucl (warning on the nondefined variable "nlines")
>It works in Allegro Trial Edition 5.0.1 for Linux (without warnings)
>It works in Lispworks Personal Edition 4.1.18 (without warnings)
>But it seems NOT to work with clisp !!! (as the former author noted, it
>blocks)

>have not looked further into it, but I found this interesting enough to
>post it.

It indeed sounds like a CLISP bug; the HyperSpec indicates that for:
read-line &optional input-stream eof-error-p eof-value recursive-p

the default value for eof-value is nil, which I'd expect to provide
the desired result.

The code's a bit ugly, but I'd sure expect the call to return "nil"
without much ado...
--
cbbro...@ntlug.org - <http://www.ntlug.org/~cbbrowne/lsf.html>
"Consistency  is  the  single  most important  aspect  of  *ideology.*
Reality is not nearly so consistent." - <cbbro...@hex.net>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.