[TUHS] Lorinda Cherry

Ralph Corderoy ralph at inputplus.co.uk
Tue Feb 22 20:39:48 AEST 2022


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.

-- 
Cheers, Ralph.


More information about the TUHS mailing list