From: nobu.nokada@... Date: 2001-12-08T13:01:22+09:00 Subject: [ruby-talk:27893] Re: Method creation question At Sat, 8 Dec 2001 06:42:57 +0900, Paul Brannan wrote: > The reason you must use an eval is that there currently is no way to get > the name of the current function. Really? Can you define a method body in runtime without eval/class_eval/module_eval? > It should be possible to get this > using an extension; I think it's stored in ruby_frame->last_func? Yes, or rb_frame_last_func(). But it cannot be provided as a method, it would just return its own ID. Or in pure ruby, try *caller(0)[0].scan(/\`(\S+)\'\z/)[0] def caller_name(level = 0) m = /\`(\S+)\'\z/.match(caller(level + 1)[0]) and m[0] end Nobu Nakada