From: Matt Mongeau Date: 2013-02-22T04:23:38+09:00 Subject: Re: THE CLASS/OBJECT CHICKEN-AND-EGG PARADOX void Init_class_hierarchy(void) { id_attached = rb_intern("__attached__"); rb_cBasicObject = boot_defclass("BasicObject", 0); rb_cObject = boot_defclass("Object", rb_cBasicObject); rb_cModule = boot_defclass("Module", rb_cObject); rb_cClass = boot_defclass("Class", rb_cModule); rb_const_set(rb_cObject, rb_intern("BasicObject"), rb_cBasicObject); RBASIC(rb_cClass)->klass = RBASIC(rb_cModule)->klass = RBASIC(rb_cObject)->klass = RBASIC(rb_cBasicObject)->klass = rb_cClass; } This is exactly what is happening. You can see it builds all of these first AND then sets the klass AFTER they are created. But to break it down further... >> "every object has an internal record" This is RBasic: 295 struct RObject { 296 struct RBasic basic; 297 struct st_table *iv_tbl; 298 }; 290 struct RBasic { 291 unsigned long flags; 292 VALUE klass; 293 }; >> " of what class it’s an instance of," See how RObject has an RBasic, see how RBasic has a klass. When rb_cObject is first created klass is a null value, later it sets that value: >> "and the internal record inside the object Class" We're talking about RBasic again here >> "points back to Class." RBASIC(rb_cClass)->klass = RBASIC(rb_cModule)->klass = RBASIC(rb_cObject)->klass = RBASIC(rb_cBasicObject)->klass = rb_cClass; That is done there. If you want more details about how these things work check out the following: http://rhg.rubyforge.org/chapter02.html http://rhg.rubyforge.org/chapter04.html -- Posted via http://www.ruby-forum.com/.