__PRETTY__FUNCTION__ for Ruby?

We have FILE and LINE

So it would be nice to have PRETTY_FUNCTION?

Is there one or do I have to roll my own out of “caller(1)[0]”?

John C. Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : [email protected]
New Zealand

Hi,

In message “Re: PRETTY__FUNCTION for Ruby?”
on Mon, 15 Dec 2008 06:23:08 +0900, John C.
[email protected] writes:

|We have FILE and LINE
|
|So it would be nice to have PRETTY_FUNCTION?
|
|Is there one or do I have to roll my own out of “caller(1)[0]”?

You mean method in 1.9?

          matz.

On Mon, 15 Dec 2008, Yukihiro M. wrote:

|We have FILE and LINE
|
|So it would be nice to have PRETTY_FUNCTION?
|
|Is there one or do I have to roll my own out of “caller(1)[0]”?

You mean method in 1.9?

Ah! Sorry! I was looking under the wrong name…

Now, thank you, I’m looking in the right place so I see…

ruby --version
ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-linux]
$ ruby -e ‘def foo;p method;end;foo’
:foo

Are you’re saying that this behaviour change in 1.9?

John C. Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : [email protected]
New Zealand

Hi,

In message “Re: PRETTY__FUNCTION for Ruby?”
on Mon, 15 Dec 2008 09:42:01 +0900, John C.
[email protected] writes:

|ruby --version
|ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-linux]
|$ ruby -e ‘def foo;p method;end;foo’
|:foo
|
|Are you’re saying that this behaviour change in 1.9?

No, 1.8.7 just added a lot of 1.9 features recently.

          matz.

On Sun, Dec 14, 2008 at 7:42 PM, John C. [email protected]
wrote:

Ah! Sorry! I was looking under the wrong name…

Now, thank you, I’m looking in the right place so I see…

ruby --version
ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-linux]
$ ruby -e ‘def foo;p method;end;foo’
:foo

Are you’re saying that this behaviour change in 1.9?

Doesn’t look like so:

sandal:Desktop $ ruby -v
ruby 1.9.1 (2008-10-28 revision 19983) [i386-darwin9.4.0]
sandal:Desktop $ irb

method
=> :irb_binding
def foo
method
end
=> nil
foo
=> :foo

Just keep in mind that Ruby 1.8.7 isn’t a compatible Ruby 1.8 version.
It’s meant for um… I don’t really know what, and if you want your
code to run on Ruby 1.8.6 (which is pretty important if you plan to
support 1.8 at all, IMO), it’s not there:

sandal:prawn $ ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin9.4.0]
sandal:prawn $ irb

method
NameError: undefined local variable or method `method’ for
main:Object
from (irb):1
from :0