[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Where is the define_singleton_method method?

Eustaquio Rangel de Oliveira Jr.

8/29/2007 4:28:00 AM

I just got the svn trunk and was testing some new stuff, but could not
find the define_singleton_method:

irb(main):001:0> [RUBY_VERSION,RUBY_RELEASE_DATE]
=> ["1.9.0", "2007-08-28"]
irb(main):002:0> a = ""
=> ""
irb(main):003:0> a.define_singleton_method(:foo){|x| x + 1}
NoMethodError: undefined method `define_singleton_method' for "":String

Running out of irc the same two lines above I get the same results:

[taq@~/code/ruby/1.9]ruby1.9 dsm.rb
dsm.rb:2:in `method_missing': undefined method `define_singleton_method'
for "":String (NoMethodError)
from dsm.rb:2:in `<main>'

Am I missing something?

Thanks!
--
Posted via http://www.ruby-....

5 Answers

Nobuyoshi Nakada

8/29/2007 7:45:00 AM

0

Hi,

At Wed, 29 Aug 2007 13:28:24 +0900,
=?utf-8?Q?Eust=c3=a1quio_Rangel?= wrote in [ruby-talk:266637]:
> I just got the svn trunk and was testing some new stuff, but could not
> find the define_singleton_method:

No such method is defined.

--
Nobu Nakada

Eustaquio Rangel de Oliveira Jr.

8/29/2007 10:27:00 AM

0

Nobuyoshi Nakada wrote:
> No such method is defined.

Thanks for your answer, but now I'm kind of lost here. There's a
reference of the method here:
http://www.ruby-doc.org/core-1.9/classes/Object.ht...

And here, where I got the previous samples:
http://eigenclass.org/hiki.rb?Changes+in+Ru...

And also on the Changelog, from Matz!:
Mon Oct 9 01:56:34 2006 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (rb_obj_define_method): add new method
Kernel#define_singleton_method. [ruby-list:42851]

I got the latest trunk using:
svn co http://svn.ruby-lang.org/repos/... ruby

I searched for rb_obj_define_method on the C code but could not find any
code for it. Searching for rb_define_singleton_method returns me a lot
of references of its internal use (as C code) and its definition on
class.c, but not as a method we can reach from the language, without a
thing like 'rb_define_method(rb_mKernel, "define_singleton_method",
rb_obj_instance_eval, -1);' there.

So, I'm lost, what happened with this method? :-)

Thanks again!
--
Posted via http://www.ruby-....

Nobuyoshi Nakada

8/30/2007 5:07:00 AM

0

Hi,

At Wed, 29 Aug 2007 19:26:39 +0900,
=?utf-8?Q?Eust=c3=a1quio_Rangel?= wrote in [ruby-talk:266659]:
> And also on the Changelog, from Matz!:
> Mon Oct 9 01:56:34 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
>
> * eval.c (rb_obj_define_method): add new method
> Kernel#define_singleton_method. [ruby-list:42851]

It seems lost at YARV merger. Reverted now.

--
Nobu Nakada

Eustaquio Rangel de Oliveira Jr.

8/30/2007 7:00:00 PM

0

Nobuyoshi Nakada wrote:
> It seems lost at YARV merger. Reverted now.

Thank you!

--
Posted via http://www.ruby-....

:))

2/20/2011 12:12:00 AM

0

You guys are seriuosly mediocre but not bunch of idiots at all.

:-))))
-----------------------------------------------------------------------------------------------------------------------
On Sat, 19 Feb 2011 15:34:11 -0800 (PST), hotac <hochimanh@gmail.com>
wrote:

>ScaiacS (0 friends, send message) wrote: 21m ago
>What exactly is the difference between "illegitimate" and "illegal"?
>Dictionaries see none. This may be the first time Washington agrees on
>something! Bully, bully!
>
>Dog:
>Hillary is showing the signs of a rough life of shady deals and lying
>husband. It is taking it's toll early on her.
>
>ICRussia (0 friends, send message) wrote: 2h 57m ago
>"Illegitimate, not illegal", just like all Chelsea's half-siblings :)
>
>I am right 2000:
>Just like Bill, Hilary struggles to define the words. 'Illegitimate,'
>not illegal, depends on the meaning of the word "is". Hilary's face in
>this particular photo looks like she is an evil puppet of Obama and
>Muslim Brotherhood.
>
>El Cid Campeador:
>I don't know what is the difference between the words ILLEGAL and
>ILLEGITIMATE.I beleive that american policy on the middle east is
>being made in Tel Aviv.
>
>mooshiefamily (35 friends, send message) wrote: 32m ago
>Illegitimate v. illegal--sounds like splitting hairs with an ally
>rather than being a diplomat.
>
>Stevek:
>Illegitimate but not illegal. Man Hillary, just don't say anything.
>
>onemoretime:
>Bill must wake up in the middle of the night and throw up.
>It really explains a lot.
>
>