------_ extPart_001_01C60224.6EE5ACC1
Content-Type: text/plain;
charset so-8859-1"
Content-Transfer-Encoding: quoted-printable
I wouldn't really call it optimization (although I guess it is), it's more like implementing them in such a way that you get around the limitations of computer memory. (As opposed to just making them run faster or something.) It doesn't really have anything to do with efficiency in that sense.
Code like:
def fun(x)
fun(x)
end
fun(10)
should run forever, like it would in a language like Scheme or Lua. A function calls itself, which calls itself, for infinitly. Unfortunately, Ruby does not currently work that way.
It's not that Ruby doesn't work "right" in this case, it just runs into the limits of hardware (the size of the stack). The "proper" way of implementing tail calls would never use the stack, so it wouldn't be an issue.
By the way, is there a particular reason why tail calls aren't implemented that way?
-Justin
-----Original Message-----
From: ruerue / purr.magical-cat.org on behalf of Eero Saynatkari
Sent: Thu 12/15/2005 7:55 PM
To: ruby-talk ML
Subject: Re: Ruby tail recursion
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 2005.12.16 12:41, Mark Ericson <mark.ericson / gmail.com> wrote:
> In another thread someone mentioned tail recursion doesn't work right
> in Ruby. Could someone please expand upon that?
The current interpreter does not do tail-recursion optimization.
This means that deeply recursive operations are not as efficient
as they could be.
E
------_ extPart_001_01C60224.6EE5ACC1--