From: ts Date: 2002-01-04T16:26:10+09:00 Subject: [ruby-talk:30183] Re: How to get top-level object from C? >>>>> "n" == nobu nokada writes: n> Sorry, I was wrong and correct it. No, you were right except for top-level method which are not really module functions n> The top-level object(main) is an instance of Object, but not n> itself. Since top-level methods are private methods of the n> main, rb_cObject can't access to the methods and instance pigeon% cat aa.c #include void Init_aa() { rb_require("uu.rb"); rb_funcall(rb_cObject, rb_intern("uu"), 0); } pigeon% pigeon% cat uu.rb def uu p "uu" end pigeon% pigeon% ruby -raa -e 1 "uu" pigeon% n> variables. It's possible to access the main with n> ruby_top_self, however, it needs a declaration now. rb_cObject can access methods but not an instance variable defined (for example) in uu.rb Guy Decoux