[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some questions



    From: glacier!franz!fimass!jkf@kim.Berkeley.EDU (John Foderaro)
    To: ucbkim!Xerox.COM!miller.pa
    Cc: common-lisp@su-ai.arpa
    Subject: Re: Some questions 


    >> Do you transform the source to continuation passing style before
    >> compiling?  
    >> How happy are you with this decision?  
    >> If you don't, do you do tail-recursion optimizations anyway?

	The Franz Inc. ExCL (Extended Common Lisp) compiler does not
    transform to a continuation passing style before compilation.  It
    detects tail-recursive calls and eliminates some self-tail-recursive
    calls and will soon give the user the option of eliminating non-self
    tail-recursive calls on certain architectures.

Unless, you're talking about self-recursive LABELS, note that
according to a discussion on this mailing list long ago, it is not
legal to implement
	(defun revappend (a b)
	  (if (null a)
	      b
	      (revappend (cdr a) (prog1 a (setf (cdr a) b)))))
with a branch back to the beginning of the code, because function
calls are defined in terms of symbol-function of the symbol that
happens to be the car of a form.  Thus you could do
	(setf (symbol-function 'foo) (symbol-function 'revappend))
and it would still be expected to call whatever is in the
symbol-function cell of revappend for recursive calls.  I'm not sure I
like this (at the timeI was suggesting that DEFUN ought to provide an
implicit LABELS so that the self-recursion did the obvious thing), but
that's what was decided.

Of course, that doesn't mean it isn't possible to do tail-recursion
elimination, as long as what you're doing is jump to the contents of
the appropriate symbol-function cell value, as opposed to a simple
branch.  Since your message said you only currently did
self-tail-recursion I'm assuming that's not what you're doing.