Does the GNU Smalltalk support tail recursion?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Does the GNU Smalltalk support tail recursion?

Dmitry Matveev
Hi everybody!

I have the following code:

| iter fact |
iter := [:n :product |
    (n <= 0) ifTrue:  [ product ]
             ifFalse: [ iter value: (n - 1) value: (product * n) ]].

fact := [:n | iter value: n value: 1].

According to the Windows Task Manager, gst memory consumption grows up
with the argument passed to fact, e.g.

st> fact value: 5000.

makes gst to use ~80 MB of RAM on my machine.

Does the GNU Smalltalk support tail recursion like Scheme? Or simply
my code is incorrect....

With best regards,
Dmitry


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Does the GNU Smalltalk support tail recursion?

Paolo Bonzini-2
> Does the GNU Smalltalk support tail recursion like Scheme? Or simply
> my code is incorrect....

No, in general Smalltalk implementations do not support tail recursion.

Thanks for your interest!

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk