Pascal Bourguignon wrote:
I tried to write a code in a style similar to yours but it seems the interpreter goes in an infinite loop of printing the first line. The function read-line is not reading beyond the first line, am i making
some trivial mistake?
I am using clisp-2.33.1 on windows.
My code:
(defun print-on-printer (file-stream printer-stream)
(loop with line = (read-line file-stream nil 'eof) until (equal
line 'eof)
do (princ line printer-stream)
do (terpri printer-stream)))
Read the loop chapter of CLHS!
http://www.lispworks.com/reference/HyperSpec/Body/m_loop.htm http://www.lispworks.com/reference/HyperSpec/Body/06_a.htm
WITH is not FOR.
John Foderaro:
I'm not trying to join a debate on loop. I just wanted to present
the other side of [the issue so that] the intelligent people can
then weigh the arguments on both sides.
I'm not suggesting that loop can be fixed either by adding
parenthesis or coming up with ways of indenting it to make it
understandable. It's a lost cause.
...
Another great example from kmp:
=== from kmp
For example, you might think
(loop with i = (random 100) for x from 1 to 10 do (print (list i x)))
and
(loop for i = (random 100) for x from 1 to 10 do (print (list i x)))
meant the same in English, [but they don't do the same thing in loop]
=== end kmp
loop lulls you into thinking that you understand the program since
you understand English. Make no mistake about it, loop is its
own language. If you use it you condemn everyone who reads the
code to also learn the loop language.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)