Subject: Re: Unable to read a list with 'with-open-file'
From: Erik Naggum <>
Date: Thu, 22 Nov 2001 17:45:32 GMT
Newsgroups: comp.lang.lisp
Message-ID: <>

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