[COFF] Tail-recursion was Re: [TUHS] Lorinda Cherry

Will Senn will.senn at gmail.com
Wed Feb 23 10:48:39 AEST 2022


My all time favorite presentation on tail-recursion:

https://www.youtube.com/watch?v=-PX0BV9hGZY


On 2/22/22 4:39 AM, Ralph Corderoy wrote:
> Hi Otto,
>
>> MacOS uses the GNU implementation which has a long standing issue with
>> deep recursion.  It even cannot handle the tail recursive calls used
>> here and will run out of its stack.
> When learning dc and seeing it relied on tail calls, the first thing
> I did was check it did tail-call elimination, and it did.  That was
> GNU dc.
>
> Trying just now, I see no growth in memory usage despite heavy CPU load
> shown by TIME increasing.
>
>      $ dc
>      !ps u `pidof dc`
>      USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
>      ralph    11489  0.0  0.0   2332  1484 pts/1    S+   10:33   0:00 dc
>      [lmx]smlmx
>      ^C
>      Interrupt!
>      !ps u `pidof dc`
>      USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
>      ralph    11489 75.5  0.0   2332  1488 pts/1    S+   10:33   0:46 dc
>
> The memory used remained at that level during the macro execution too,
> watched from outside.
>
> Do you have more detail on what GNU dc can't handle?  dc without
> tail-call elimination is a bit crippled.
>



More information about the COFF mailing list