Re: Multivalue tail recursion?





So my question is this: does this count as tail recursion? The actual
"last operation" of the function is just repackaging the values
returned from the recursive call. Can lisp's compiler optimize this
into a loop?

Common Lisp does not promise tail call elimination of any kind, so
whether this gets optimised is entirely dependent on the
implementation. If you need it to be a loop on any implementation,
you should write it as one (indeed the LOOP macro is the absolute king
of clarity for doing something like this.


And, secondarily, is it considered naughty to use variables like
"list" and "rest" that are built-in function names?

No. Indeed since it causes Lisp-1 people to go red in the face it is
considered particularly good style. If you can cause them actually to
burst Kenny will send you a reward.

--tim


.