From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!news.worldonline.be!nslave.kpnqwest.net!nloc2.kpnqwest.net!nloc.kpnqwest.net!nmaster.kpnqwest.net!nreader1.kpnqwest.net.POSTED!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: Unable to read a list with 'with-open-file' References: <604dab8.0111220655.28c1fb26@posting.google.com> Mail-Copies-To: never From: Erik Naggum Message-ID: <3215439930132888@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 48 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 22 Nov 2001 17:45:32 GMT X-Complaints-To: newsmaster@KPNQwest.no X-Trace: nreader1.kpnqwest.net 1006451132 193.71.66.49 (Thu, 22 Nov 2001 18:45:32 MET) NNTP-Posting-Date: Thu, 22 Nov 2001 18:45:32 MET Xref: archiver1.google.com comp.lang.lisp:20759 * Cad Bilbao | (setf myList '()) | (with-open-file (f "c:/input.txt" :direction :input) | (loop for line = (read-line f nil nil) | while line | do ( | (setf myList(append myList line) | );end-do | );end-while | );end-loop | );end-with Well, get rid of the terribly confusing ;end-crap first (the comments do not even match what they say they match), and try to see how other people write their Common Lisp code. If you do things differently from more experienced people, you do _not_ know better because you are new at this. That attitude may be at the core of your problem, actually, since you have not paid attention to how parentheses "work" in Common Lisp. From your indentation style alone, it appears that you think they have a very different function than what they actually have. When you have figured out the invalid function error, retrace your steps and figure out where you got the terrible idea to use append, then do the same for that global variable. Otherwise, you have it mostly right. | But I get this error: | | ------------------//--------------- | LISP error: | (SETF TEST::MYLIST (APPEND TEST::MYLIST LINE)) is invalid as a | function | -----------------//--------------- | | Any suggestion? Than you very much The error message is actually very precise. Try to evaluate ((+ 1 1)) and see what it says. Compare with (+ 1 1). Also count the number of parentheses you use in your code carefully. Get an editor that helps you keep track of them and takes care of that indentention stuff for you, too. /// -- Norway is now run by a priest from the fundamentalist Christian People's Party, the fifth largest party representing one eighth of the electorate. -- Carrying a Swiss Army pocket knife in Oslo, Norway, is a criminal offense.