Pascal Bourguignon <email@example.com> wrote:
| Alain Picard <Alain.Picard@memetrics.com> writes:
| > Pascal Bourguignon <firstname.lastname@example.org> writes:
| > > [Personally, I prefer:
| > > (defun average (&rest args) (/ (apply (function +) args) (length args)))
| > ... (/ (reduce (function +) args) (length args))
| > This way you won't croak if you have more than CALL-ARGUMENTS-LIMIT args.
| Note however that CALL-ARGUMENTS-LIMIT minimum is specified to be 50,
| so the "newbie" code could lead to problems only on a multi-line
| (average ...) sexp, or an (apply (function average) arg-list).
Sounds like a great opportunity for a tutorial on compiler macros!
First, show the REDUCE version [which should always be the default],
then show a compiler macro that examines the length of the arg list
and if it's less than CALL-ARGUMENTS-LIMIT rewrites it into the APPLY
Rob Warnock <email@example.com>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607