emacs-devel
[Top][All Lists]
Advanced

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

Re: tail-call elimination


From: Stefan Monnier
Subject: Re: tail-call elimination
Date: Tue, 11 Dec 2012 08:34:11 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>> I have attached a patch that implements tail-call elimination for
>> a subset of emacs lisp.  This will be helpful in allowing coding
>> styles which emphasize tail recursion, such as is usual in languages
>> like Scheme.
> Your patch eliminates tail calls only in byte compiled code.  Until the
> interpreter also supports guaranteed tail call elimination or we byte-compile
> all forms before evaluating them, elisp developers cannot rely on the
> optimization and cannot write idiomatic tail recursive code.

I'm not too worried about that.  For one, you can argue that bumping
into max-lisp-eval-depth for lack of byte-compilation is similar to being
too slow for lack of byte-compilation.  And in any case we can hope that
non-byte-compiled code is on the way to extinction.

> As a purely opportunistic optimization, not as a guaranteed language
> feature, I doubt tail call elimination is worth the complexity.

If it speeds up execution, I think it can be worth the trouble.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]