On Nov 13, 10:49 pm, Chet Nichols III <chet.nich... / gmail.com> wrote:
> i get a recursive depth of about 350,000 before it bombs out (which is what
> i'd expect more or less). i know C is super efficient and all, and ruby is
> truly object oriented, so each thing pushed on the stack is an object with
> its own set of methods, etc, so its by design going to take up more space,
> but i was wondering if there are any plans to do anything to help the
> efficiency of this at all?

Your wording seems to imply that you believe that each object has its
own copy of all of its class' methods.  Although Ruby does allows you
to add a method to a specific instance (the so-called "singleton
method"), in general all instances of a class share one "copy" of the
method.  Each instance only needs to maintain its instance variables.

Furthermore, objects, in general, tend to be stored on the heap, not
the stack.  References to the object may be stored on the stack.  Ruby
has some optimizations, such that Fixnums are handled in a special way
and do appear on the stack.  But they take the same amount of space as
a reference anyway.

So as far as the Ruby call stack is concerned.  Rich DeNatale's post
in this thread is probably more accurate at describing why MRI (Matz's
Ruby implementation) has this problem.  Other Ruby implementations,
such as Rubinius, likely will not.

Eric

====

Interested in hands-on, on-site Ruby training?  See http://LearnRuby.com
for information about a well-reviewed class.