From: Yehuda Katz Date: 2009-01-19T18:20:31+09:00 Subject: [ruby-core:21431] Re: Proposal: Module#copy_method --0015174c3f5ca5edc40460d25b03 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit In particular: if(nd_type(node) == NODE_CFUNC && !(rb_class_inherited_p(self, klass))) { rb_raise("you can not move a c function to an incompatible class"); } -- Yehuda On Mon, Jan 19, 2009 at 2:04 AM, Yehuda Katz wrote: > 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 > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 --0015174c3f5ca5edc40460d25b03 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable In particular:

if(nd_type(node) =3D=3D NODE_CFUNC &= amp;& !(rb_class_inherited_p(self, klass))) {
  rb_= raise("you can not move a c function to an incompatible class");<= /div>
}

-- Yehuda

On Mon, Jan= 19, 2009 at 2:04 AM, Yehuda Katz <wycats@gmail.com> wrote:
Matz,

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

-- Yehuda

On Mon, Jan 19, 2009 at 1:10 AM, Yukihiro Matsumoto <<= a href=3D"mailto:matz@ruby-lang.org" target=3D"_blank">matz@ruby-lang.org> wrote:
= Hi,

In message "Re: [ruby-core:21399] Proposal: Module#copy_method"
   on Sun, 18 Jan 2009 16:26:19 +0900, Yehuda Katz <wycats@gmail.com> = 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 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
Developer | Engine Yard
(ph) 718.877.1325



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