Kent M Pitman <firstname.lastname@example.org> wrote:
| email@example.com (Rob Warnock) writes:
| > I tend to prefer the Scheme-style default for the non-list arg case:
| > (defmacro \\ (args &body body)
| > `(lambda ,(if (listp args) args (list '&rest args)) ,@body))
| Maybe you'd like
| (defmacro \\ (args &body body)
| `(lambda ,(do ((args args (cdr args))
| (temp '() (cons (car args) temp)))
| ((atom args)
| (if (null args) ; was it a proper list?
| (nreverse temp) ; if so, just reverse saved args
| (nreconc temp ; otherwise, reverse most and add tail:
| (list '&rest args)))))
| even better.
Well, yes, if I were a Scheme purist, very probably. ;-}
But once the arglist gets as big as (a b . rest) it's
not *that* much more trouble to go ahead and write out
(a b &rest rest). It's really "x" versus "(&rest x)"
that's the big convenience. IMHO. YMMV. Etc., &c.
Rob Warnock <firstname.lastname@example.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607