[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: __PRETTY__FUNCTION__ for Ruby?

Yukihiro Matsumoto

12/14/2008 11:01:00 PM

Hi,

In message "Re: __PRETTY__FUNCTION__ for Ruby?"
on Mon, 15 Dec 2008 06:23:08 +0900, John Carter <john.carter@tait.co.nz> 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.

2 Answers

John Carter

12/15/2008 12:42:00 AM

0

On Mon, 15 Dec 2008, Yukihiro Matsumoto 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 Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : john.carter@tait.co.nz
New Zealand


Gregory Brown

12/15/2008 4:08:00 AM

0

On Sun, Dec 14, 2008 at 7:42 PM, John Carter <john.carter@tait.co.nz> wrote:
> On Mon, 15 Dec 2008, Yukihiro Matsumoto 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?

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