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

Tail Recursion

    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:
        a) tail-recursion loses stack backtrace information, which may
           be crucial to debugging.

I agree.  So make it optional.

        b) tail-recursion is non-obvious and disguises an iterative
           procedure as a function call.

This is a style point.  I intensely dislike having it forced on me.  My LISP
background is a decade later than many of the Symbolics development team's,
coming from SCHEME in the early 80's.  I'm used to recursion, and find it 
obvious, easy to read, and faster to write [it certainly uses less space on the

Perhaps we should send in bug reports.  Maybe if enough of them make it in...

-- Stephen