Shared DynamicSites don't get initialized for each specific class/object and method combination. A shared DynamicSite applies to all invocations of a method like to_int. The DLR validates the context in which the invocation occurred and then invokes the dynamic site's target (a delegate) for the object.
Rather than have tons of permutations of varying types baked into the DLR, they chose to use rule sets (as described in Martin Maly's blog) to determine which operation(s) should be performed on objects to achieve desired results and cache these rule applications so that it doesn't have to evaluate these rules over and over again (like, for instance, in a loop where the same operation is being iterated many times). Keep reading the code -- RubyBinder.cs in the Ruby project and DynamicSite.cs in the Microsoft.Scripting project -- to see how this happens for IronRuby. RubyBinder.cs should answer your question about why the behavior is different between InvokeMember and ConvertTo. Briefly, the Ruby action binder applied different rules to these invocations. Maybe one day someone with more acumen and expertise than myself will write a book about how the DLR works internally like what Don Box, Jeff Richter, and others did for the CLR. It'll be easier to comprehend then. In the meantime, you'll just have to rough it on the bleeding edge. ;) -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list [email protected] http://rubyforge.org/mailman/listinfo/ironruby-core
