From: "Aleksi Niemelä" Date: 2000-12-16T05:51:38+09:00 Subject: [ruby-talk:7347] RE: Different id's for the Object meta class? > In a Ruby extension if I execute the following three lines I get > three different values for the identifier of the Object: I know nothing about these things, so I'm just guessing. Beware. > rb_eval_string("print 'Object.id: ', Object.id"); > Object.id: 5919960 Here you pass a string to Ruby C-api, to evaluate (compile & execute) it. Thus the code in Ruby prints the id in Ruby world for the object which constant Object refers to. > printf("\nrb_cObject: %d", rb_cObject); > rb_cObject: 58992127 Here you print right away on your own the address where rb_cObject pointer (variable) points to, through a normal C-idiom. I'd expect it points to somekind of struct representing Ruby object which in turn has a placeholder for the id attribute. Now we're completely on the C world (assuming the code was in C and not in Ruby :). > printf("\ncObject: %d", rb_eval_string("Object")); > Object: 11839920 Here you first ask Ruby to evaluate (compile&execute) string "Object", which in turn returns you an Ruby object (C pointer pointing to struct representing Ruby object). Then you just print the (C-) address of that returned object (converting from pointer magically to integer in C way). > What am I misunderstanding? I guess nothing, except if you assume the all the above cases to print same thing. I'm sure people will correct me here, if I was guessing wrong. - Aleksi