From: Yehuda Katz Date: 2009-01-19T18:04:35+09:00 Subject: [ruby-core:21430] Re: Proposal: Module#copy_method --0015174bdfec3340220460d23b5e Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Matz, Couldn't we just filter out all c-funcs from copying? -- Yehuda On Mon, Jan 19, 2009 at 1:10 AM, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [ruby-core:21399] Proposal: Module#copy_method" > on Sun, 18 Jan 2009 16:26:19 +0900, Yehuda Katz > writes: > > |I'd like it to be possible to copy methods from one module to another. The > |rationale is that this feature would make it possible to modify existing > |methods without being forced to resort to aliasing. Here's an > implementation > |that works on 1.8 and 1.9: > > This implementation can easily cause segmentation fault, since many C > implemented method does not check type of their receivers. Try > > class Foo > copy_method Bignum, :odd? > end > Foo.new.odd? > > for example. The issue is more difficult than it seems. I've had > similar issue when we implemented Method#bind, this one is even > tougher. > > matz. > > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 --0015174bdfec3340220460d23b5e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Matz,

Couldn't we just filter out all c-funcs from c= opying?

-- Yehuda

On Mon, Jan 19, 2009 at 1:10 AM, Yukihiro Matsumoto <= ;matz@ruby-lang.org> wr= ote:
Hi,

In message "Re: [ruby-core:21399] Proposal: Module#copy_method"
   on Sun, 18 Jan 2009 16:26:19 +0900, Yeh= uda Katz <wycats@gmail.com> w= rites:

|I'd like it to be possible to copy methods from one module to another.= The
|rationale is that this feature would make it possible to modify existing |methods without being forced to resort to aliasing. Here's an implemen= tation
|that works on 1.8 and 1.9:

This implementation can easily cause segmentation fault, since many C=
implemented method does not check type of their receivers.  Try

 class Foo
   copy_method Bignum, :odd?
 end
 Foo.new.odd?

for example.  The issue is more difficult than it seems.  I'v= e had
similar issue when we implemented Method#bind, this one is even
tougher.

                    &nbs= p;                     &n= bsp;            matz.




--
Yehuda Katz
Develope= r | Engine Yard
(ph) 718.877.1325
--0015174bdfec3340220460d23b5e--