[Ironruby-core] Couple of Questions

Tomas Restrepo tomas at winterdom.com
Sun Feb 24 09:06:24 EST 2008

Hi Joe,

>  Check out Martin Maly's blog for an explanation of how DynamicSites
>  work.

First of all, thanks for answering. I'm aware of Martin's blog and
it's a very nice resource, but honestly, the details still seem a bit
hazy to me. In particular:

Does this mean that a shared DynamicSite gets set up [1] for a given
class/object and specific method during the first Invoke() call? If
so, does calling DynamicSite.RespondTo() potentially setup the site
for a given target as well? (I'm guessing yes, otherwise I can't quite
see how the code could possibly work, but it would be nice to have

Actually, this kind of brings another question:
As far as I can see, the shared DynamicSites are there to support the
IronRuby runtime/libraries themselves needing to use the ruby bindings
for specific methods, which is fine. But they are not involved when
the runtime is simply calling a method explicitly based on the code.

Take, for example, this simple piece of code:

x = Mine.new
print x.to_s
print x

Where Mine is some arbitrary class implementing a to_s() method.

Now, the first call is invoked using the normal InvokeMember action
semantics in IronRuby. The second one has an implicit to_s() call from
print, which actually uses the shared RubySites.ToSSharedSite site.
(it's easy to check using the debugger that the first explicit call
doesn't go through the shared site, as expected)

If so, then this would seem to imply that after this small snippet of
code executes there are at least two sites caching the rule for
Mine.to_s. Is my understanding of it correct? And if so, are there any
implications of that? (I can guess it might involve some memory

As I said, I'm just trying to understand what's going on in the code.
Feel free to whack me in the head with the rod of enlightenment if I'm
just asking stupid questions :)

[1] I realize the term here might not be the most appropriate.

Tomas Restrepo

More information about the Ironruby-core mailing list