John Lam 1997 — 2026

RubyCLR update

It’s been a long time since I’ve updated you on the status of RubyCLR.

I’ve had some cycles this week to start working on squashing bugs in RubyCLR. The nasty one was due to my bone-headed implementation of the proxy object cache. Bottom line: I relied on Object.GetHashCode() to provide process-wide unique identifiers which, of course, it does not. Frankly I’m rather embarrassed that I made this bug.

I have fixed my object cache to use GetHashCode() to assign objects to buckets, but I do a manual Object.Equals(a, b) comparison as I walk the bucket list to look up the appropriate CLR proxy object. So I now handle identity correctly. Note that identity is still wierd with respect to interfaces, but that’s going to be a longer-term fix.

I have also implemented shadow class inheritance. This lets me add helper methods to base shadow classes that propagate to derived shadow classes. This lets me be much more efficient in memory since method shims exist exactly once in an inheritance hierarchy whereas they used to be duplicated. So this lets me add a lovely helper method for doing some WPF coding:

``` import System::Windows::FrameworkElement class System::Windows::FrameworkElement def [](name) self.find_name(name) end end ```

The import directive creates a shadow class object for FrameworkElement. I then define a method for the square bracket operator which delegates the call to the FindName method of FrameworkElement. This lets me do this from anywhere in my code:

``` w = Wpf.load('myxaml.xaml') w['button1'].click do |sender, args| puts 'clicked me!' end ```

Update: I’ve had a lot of problems trying to check in source code changes to RubyForge recently. I haven’t had the cycles to track down this problem, so I’ve created a new release for this code update. You can get it from here.

5 archived reader comments

Craig (2006/07/19)

Did you mean "Object.ReferenceEquals" ? I know nothing about your project, it just seems more appropriate if what you were trying to do was to determine identity rather than equivalance…

John Lam (2006/07/19)

You’re absolutely right, Craig. I don’t know what I was thinking. I’ve fixed it in the sources. Thanks for the catch!

gertjan (2006/05/20)

Just sent you a mail with a ‘gem-enabled’ RubyCLR… About .NET 1.1: thanks for the timesaving answer. Definitely not feasible to try to simulate DynamicMethods in .NET 1.1 managed code.

John Lam (2006/05/21)

Which address did you send it to? I haven’t seen it yet. You can reach me via jlam at this domain.

gertjan (2006/05/22)

Retrying… Maybe the prebuilt .gem (which is a zip file in disguise) was blocked somewhere along the way.