4 ms·
Common Lisp doesn't require tail-call support (though some implementations have it).
by hajile 7y ago
Common Lisp doesn't require tail-call support (though some implementations have it).
- DannyB2 7y agoWhile tail call is an optional feature in CL, are there any (or very many) implementations that DO NOT have tail call elimination? (just curious)
- kazinator 7y agoTail recursion can be cobbed together with macros. This is particularly effective for recursion among local functions in the same lexical scope: http://www.kylheku.com/cgit/lisp-snippets/tree/tail-recursion.lisp http://www.kylheku.com/cgit/lisp-snippets/tree/tail-recursio... The above tail recursion macros achieve local tail calls by transforming to a tagbody with go. This is offered in the form of a tlet macro whose syntax is like labels. Write your mutually tail recursive functions as labels, then change labels to tlet to try it with this. tlet is based on argtags: a form of tagbody whose labels take arguments. These arguments perform a re-assignment of local variables from parameters that accompany the goto transfer. Tail calls among top-level functions are supposed by a complementary facility called deftail which uses a combination of non-local dynamic control transfers and a dispatch trampoline.