Subject: Re: Append considered harmful?
From: rpw3@rpw3.org (Rob Warnock)
Date: Mon, 05 Apr 2004 06:18:17 -0500
Newsgroups: comp.lang.lisp
Message-ID: <CemdnVRcgPzk3ezd4p2dnA@speakeasy.net>
Tim Bradshaw <tfb+google@tfeb.org> wrote:
+---------------
| I think there's a difference between premature opimization and things
| that are complexity-classes worse than they need to be and that may be
| in inner loops. This kind of thing:
|    (let ((results nil))
|      (loop ...
|            do (setf results (append results x)))
|      results)
| is a disaster waiting to happen.  And you do see it fairly often in
| things people write...
+---------------

(sigh*)  Yes, one does... Yet...

<rant intensity="mild">
I wonder if it might not happen so often if REDUCE had an additional
keyword argument, say :MAX-ARITY (default 2), which said how many
arguments the function being used to REDUCE the sequence could accept.
Then a lot of the sorts of LOOPs you note above could be performed
by calls to (REDUCE #'fcn sequence :MAX-ARITY CALL-ARGUMENTS-LIMIT),
allowing the work to be done safely in "big chunks".
</rant>


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607