From: ts Date: 2001-06-21T21:04:17+09:00 Subject: [ruby-talk:16698] Re: how to call super from singleton method? [[ Do the news<=>mail gateway insert "undisclosed-recipients: ;" in the To: field ? It give me errors. ]] >>>>> "A" == Andi Riedl writes: A> ruby:0:in inspect': superclass method inspect' must be enabled by A> rb_enable_super() (NameError) A> from ruby:0 Well, you have the bad solution to use rb_enable_super(). Probably the best is to call rb_alias() and then call the new function, i.e. pigeon% cat tt.c #include #include VALUE myInspect (VALUE self) { printf ("myInspect\n"); return rb_funcall(self, rb_intern("inspect_old"), 0); } int main() { VALUE x,y; ruby_init(); x = rb_hash_new(); rb_alias(CLASS_OF(x), rb_intern("inspect_old"), rb_intern("inspect")); rb_define_singleton_method(x, "inspect", myInspect, 0); /* call now: */ y = rb_funcall(x,rb_intern("inspect"),0); printf ("%s\n",STR2CSTR(y)); return 0; } pigeon% pigeon% tt myInspect {} pigeon% Guy Decoux