David Trudgett <dtrudgett@yahoo.com> wrote:
+---------------
| There is nothing elegant about using recursion to do non-recursive
| tasks, when there are better tools to hand. Minimalism as per the
| Scheme credo is not the only kind of elegance, although Scheme is
| really quite neat in its own way. For instance, it's cool to be able
| to write stuff like:
|
| ((generate-operation x y z) arg1 arg2 arg3 arg4)
+---------------
You can do that in CL too with only one more token:
(funcall (generate-operation x y z) arg1 arg2 arg3 arg4)
To me the elegance of that is in the dynamically-generated closure,
*not* in being able to write function calls in the Scheme way per se.
+---------------
| ...although I am not sure of the extent of the practical advantage
| to being able to write things like that.
+---------------
Any number of cases where GENERATE-OPERATION might do some sort
of expensive pre-computation, the results of which are then cached
in the returned closure for use multiple times, e.g.:
(mapcar (generate-operation x y z) sequence1 sequence2 sequence3)
(remove-if-not (generate-operation x y z) sequence)
And the classic case: GENERATE-OPERATION compiles a pattern
specified at runtime into an optimized match routine, which is
then used many times when scanning the lines of a large file, e.g.,
<http://weitz.de/cl-ppcre/#create-scanner2> followed by using the
result in a loop with <http://weitz.de/cl-ppcre/#scan>, or the like.
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607