[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
tail recursion optimization
I am not convinced the manual is unambiguous. This another one of
the cases where your lisp culture influences your interpretation. On
a lisp machine, doing a function call always means indirecting through
the definition cell, so it is obvious to you that a self call will
indirect through the definition cell. People who are used to using
tail-recursion instead of loops will think that it is just as obvious
that a tail-recursive self call turns into a branch.
Spice Lisp, and probably other implementations, do this particular
optimization, so the manual certainly wasn't sufficiently overt about
disallowing it. We definitely need a clarification one way or the
other, and it makes a great deal of sense to me to optimize the 99.99%
case instead of the perverse one. You do need a way to inhibit this,
but as I already said, that can be done with NOTINLINE.
If this were a beauty contest then you would surely win, since Common
Lisp doesn't currently have any way to talk about this sort
of compile-time binding of global names. I think that this
deficiency should be remedied by adding a notion of block
compilation. On conventional architectures, there are huge advantages
to resolving a function reference at compile time. To me, a defun is
just a degenerate block which contains only one definition and one
entry point.
Rob