Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/06/22
Subject: Re: Newbie asking for help
* The Glauber <theglau...@my-deja.com>
| I'm having trouble going from the tutorials to the real world. For | example, a lot of what i do is related to processing text files. | So, i though i'd write a simple/stupid program to count the number | of lines in a file. Here it is: | | ;; 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)))) You're using a free variable, nlines, in this code. You should not | It doesn't work (it just hangs, so i think it's stuck in the loop). Try being explicit in the value of eof-value, i.e. (read-line ifile nil nil) | I thought it would read lines until the end of the file, when the I think it would be instructive to print the value from read-line: (print (read-line ifile nil)) print returns its value. | I'm sorry for posting something so stupid, but why doesn't this work? Seems like a bug in your Common Lisp implementation. Which is it? #:Erik 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.
| ||||||||||||||