trans. (T. Onoma) wrote:

> Wondering what the conscensus is on the best name for "this method". Right now 
> I'm using #calling, taking after #binding, but I'm not so sure about it. I've 
> also considered #this or #thus, to be more along the lines of 'self'.

JavaScript uses callee for the first-class version.

>   # Returns the current method or method name
>   def calling(firstclass=false)
>     m = /\`([^\']+)\'/.match(caller(1).first)[1]
>     return ( firstclass ? method( m ) : m.intern )
>   end

Personally, I'd dump the first-class logic and call it method_name. It 
is easy enough to turn that into a Method anyway.

> Also, will a method like this be implemented in future Ruby?

I'm not sure about this. (Is it needed frequently?) But right now I'd 
prefer Binding.of_caller to be in Ruby itself. After all it is needed 
for wrapping eval() and it can not be done with a pretty interface in 
plain Ruby. (It can be done in Ruby if you turn it inside out, e.g. make 
it yield a value instead of returning it.)

> Thanks,
> T.

Regards,
Florian Gross