ruby objects, classes and eigenclasses

October 29, 2008

while working on a little ruby metaprogramming, i realised i didn’t understand how objects, classes and eigenclasses relate to each other in ruby

_why helped some, but i still wasn’t completely clear

i undertook an investigation, with ruby 1.8.6 ( mri and jruby 1.1.4 ), and ruby 1.9 ( mri )

the two 1.8.6 rubys are consistent with each other, but different from ruby 1.9. method resolution seems to function similarly in both 1.8.6 and 1.9, but eigenclasses are referenced differently

this diagram captures what i found

relationships between ruby objects, classes and eigenclasses

relationships between ruby objects, classes and eigenclasses

(pdf: ruby objects, classes and eigenclasses )

Advertisements

One Response to “ruby objects, classes and eigenclasses”

  1. banisterfiend Says:

    heya, this isn’t bad, but:
    * meta-classes are not lazily created in MRI 1.8 or 1.9 (see class.c)
    * the superclass of the metaclass of A is not the metaclass of class (it’s the metaclass of Object)
    * you miss out many class/eigenclass arrows

    An accurate 1.8.6 diagram can be found here:
    http://banisterfiend.wordpress.com/2008/11/25/a-complete-ruby-class-diagram/

    And an accurate 1.9 diagram can be found here:

    🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: