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

Tail Recursion



    Date: Wed, 22 Feb 89 11:52 EST
    From: Stever@YUKON.SCRC.Symbolics.COM (Stephen Robbins)

	Date: Wed, 22 Feb 89 09:27 EDT
	From: GODDEN%gmr.com@RELAY.CS.NET

	 >From: Jeffrey Mark Siskind <Qobi@zermatt.lcs.mit.edu> 
	 >Jonathan Rees has a Scheme compiler for the 3600. I have never used it 
	 >so I can't comment on its quality. Actually I would very much like 
	 >the plain 3600 Common Lisp compiler to support tail recursion (and 
	 >continuations as well --- though the latter would require some 
	 >extensions to the language.) Many times I have taken to writing loops 
	 >instead of tail recursive calls solely for performance reasons and 
	 >would like to be able to stop that practise. 
	 >        Jeff

	I thought the CL compiler DID support tail recursion properly?
	At least, when I disassemble tail-recursive code I see a CALL-1-RETURN
	which I have been (improperly?) assuming corresponded to a branch
	instruction, nicht wahr?

    Nope.  CALL-1-RETURN leave a stack frame.

    I've asked for years for some way to allow tail-recursion.  DCP sent me
    an excellent discussion of tail-recursion issues (which I've long since
    deleted), which boiled down to two points:
I suspect there must have been more points which you've forgotten.  One problem
is that there is a fair amount of state associated with a stack frame that pertains
to cleanup now that would have to be stored elsewhere if multiple invocations of
a function shared a stack frame.  Two that come to mind immediately are unwind-protects
and stack-consed-presentation cleanups.

Also, how do you set the trap-on-exit flag on one (but not several) of these tail-recursively
called frames?