Subject: Re: Tail recursion & CL
From: Erik Naggum <>
Date: Mon, 01 Oct 2001 23:40:39 GMT
Newsgroups: comp.lang.lisp
Message-ID: <>

* Bruce Hoult
| A function call is either the last function call in the body of the
| function or else it is not.  If it's last then tail-call it (with a
| "jump"), if it's not last then call it the regular way (with a "jump to
| subroutine").

  But this is not quite as trivial as people seem to think.  There are all
  kinds of low-level cleanup issues that may not be visible or even known
  to the programmer and which the compiler writer may need to be told about
  (either through a formal specification of a requirement or by invoking a
  local declaration) before it makes sense to allow for making a tail call
  into a jump.  Also note that the callee needs to believe that it was
  called, unless the language has specified semantics to this effect, too.

| "Last" means either the last expression evaluated in the function.  This
| means either being physically last, or else being the last expression in
| an IF or COND (etc) that is physically last in the function.

  I think you might mean the form that evaluates to the value of the
  function.  It might, for instance, be possible to unwind special bindings
  and unwind-protect forms in such a way that you could jump to a function
  with it returning to the cleanup forms, so the notion of "last" might be
  very confusing and counterproductive.