m4-discuss
[Top][All Lists]
Advanced

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

Re: tail calls


From: Eric Blake
Subject: Re: tail calls
Date: Tue, 31 Oct 2017 08:43:45 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

On 10/30/2017 09:22 PM, Doug McIlroy wrote:
> Does anyone know offhand whether m4 optimizes tail calls (i.e. discards the 
> calling
> stack frame)?

There are some experimental patches I wrote years ago (ca. 2009) that
optimize handling of $@ for more efficient tail calling; but I never got
them fully implemented.  And it wasn't true tail call elimination (where
the stack frame does not grow), so much as better handling of strings to
reuse a pointer to mid-string rather than copying around a shrinking
suffix everywhere.  It did reduce some recursion schemes from O(n^2) to
O(n), but probably wasn't quite what you are referring to.

Maybe if I could find some free time I should try to revive some of
those patches, as it may help some of m4's heavier clients (such as
autoconf) - although one of the reasons I remember dropping work on the
m4 patches was that I instead patched autoconf itself to avoid some
pointless copying by using smarter iteration in the first place rather
than naive recursion that triggered m4's O(n^2) behaviors.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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