Re:ChrysaLisp
by hajile on Monday January 13, 2020 @01:41PM
(#22037234)
Common Lisp doesn't require tail-call support (though some implementations have it).
[ Parent
| on HN ]
Tail 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-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.