It appears that the scheme implementation in STk 2.1 is not "properly
tail-recursive" as mentioned in R4RS section 1.1. Is this true, or am
I misunderstanding something?
Section 1 of the STk Reference Manual doesn't mention any
non-compliances with respect to the same section of R4RS.
Here's my example code (which, I think, is tail-recursive, n'est-ce pas?):
(define loop
(lambda (count)
(if (= 0 (remainder count 1000))
(format #t "~a\n" count))
(loop (+ count 1))))
(loop 0)
The memory usage increases continuously as shown below:
[...] SIZE SWAP RSS [...] COMMAND
[...] 1980 0 1980 [...] /usr/local/lib/stk/stk-bin -name stk -f ./testit
[...] 2520 0 2520 [...] /usr/local/lib/stk/stk-bin -name stk -f ./testit
[...] 2580 0 2580 [...] /usr/local/lib/stk/stk-bin -name stk -f ./testit
[...] 3000 0 3000 [...] /usr/local/lib/stk/stk-bin -name stk -f ./testit
[...] 3484 228 3256 [...] /usr/local/lib/stk/stk-bin -name stk -f ./testit
[...] 3552 340 3212 [...] /usr/local/lib/stk/stk-bin -name stk -f ./testit
[...] 3600 192 3408 [...] /usr/local/lib/stk/stk-bin -name stk -f ./testit
[...] 3600 192 3408 [...] /usr/local/lib/stk/stk-bin -name stk -f ./testit
[...] 4992 224 4768 [...] /usr/local/lib/stk/stk-bin -name stk -f ./testit
[...] 5036 584 4452 [...] /usr/local/lib/stk/stk-bin -name stk -f ./testit
[...] 7152 1120 6032 [...] /usr/local/lib/stk/stk-bin -name stk -f ./testit
[...] 7152 2944 4208 [...] /usr/local/lib/stk/stk-bin -name stk -f ./testit
The SIZE column is in KB, and a "ps" snapshot was taken every 5
seconds.
I stopped my program after about 400000 "iterations" because it was
using 7MB of virutal memory and starting to swap badly -- I was also
running X11 and emacs at the same time with only 8M of RAM. (Linux
held up fine though!)
--
Grant Edwards
Rosemount Inc.
grante_at_rosemount.com
Received on Mon Oct 03 1994 - 22:39:55 CET