>>>>> "SDS" == SDS <···········@cctrading.com> writes:
SDS> 2. The type declaration of res in dot2 doesn't change the performance
SDS> noticeably (1%?), and, probably, it should not.
I don't think CLISP really takes advantage of declarations.
SDS> 3. On a second thought, it would seem that both versions should have the
SDS> *same* performance: a smart compiler (in a lazy language, at least)
SDS> should be able to recognize that no consing is really necessary in dot1
SDS> in the first place. Of course, lisp is strict, and both map and reduce
SDS> are functions, so *technically* consing is inevitable. OTOH, WIBNI lisp
SDS> could unfold things like this into loops?
If you can see it, a sufficiently smart compiler should be able to see
it too.
You may want to look at the series package available in the CMU Lisp
archives and described in CLtL2. Your example could be written as
(defun dot-s (l0 l1)
(collect-sum (#M+ (scan l0) (scan l1))))
which would be macro expanded into a loop. With appropriate
declarations (and good compiler), you could pretty good code out of
it.
Ray