Subject: Re: lisp idiom for processing each line in a file?
From: (Rob Warnock)
Date: Sun, 26 Feb 2006 19:35:06 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
Duncan Harvey <> wrote:
| Rob Warnock <> wrote:
| > 4. [Minor] Use LOOP instead of DO for the iteration, mainly because
| >    it's more concise [not that that matters much inside a macro].
| Isn't that a bad idea?  Wouldn't it cause something like this to
| misbehave, for instance?:
|   (loop for pathname in '("a" "b" "c" "d")
|         do (do-file-lines (line pathname :direction :input)
|              (when (some-condition-met-p line)
|                (loop-finish))

Well, that *might* be also construed as a "feature", that is, it
gives one the ability to do an early termination on a given file. ;-}

But your point is taken -- if an iteration macro does choose
to emit a LOOP, it should state so explicitly, e.g., add the
following to the doc string previously shown: "Uses LOOP to
perform the iteration, so a (LOOP-FINISH) within BODY will
terminate the iteration and close the file."

Note that I already had some obvious qualms about declarations,
which is why the default :KEY function case wrapped a null LET
around the BODY, just so that declarations would work. Otherwise
a simple "DO ,@BODY" splice would have sufficed.

What do others think? Are these sorts of conflicts common and
serious enough to ban the emitting of LOOP from (most) iteration


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607