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 )

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:
    http://yugui.jp/images/uploaded/20081214-metahierarchy-00.png

    :)


Leave a Reply