From: Logan Capaldo Date: 2006-09-26T21:47:22+09:00 Subject: Re: How to copy a method from one class to another On Tue, Sep 26, 2006 at 05:24:48PM +0900, Robert Dober wrote: > On 9/25/06, Gavin Kistner wrote: > > > > > >Ruby's methods are not first-class functions like Lua or JavaScript > >have. Other, first-class functions exist (procs/lambdas), but Methods > >are not these. > > > I tend to disagree, I do not know about Lua, but for me Ruby's methods are > pretty much first class Sometimes people define first class in terms of the additional syntax compared to other things you must use. > > class A > def a; puts "#{self} == 42"; end > end > class B < A > define_method :another_a, A.instance_method(:a) > end > AA = Class.new A > > A.new.a > A.instance_method(:a).bind(AA.new).call > B.new.another_a > > > I do not know what can be done more in Lua and JavaScript but would be happy > to know. > > > Interesting. Doesn't work outside of inheritence hierarchys though, where in JavaScript you could. (Lua of course has no object system, save whatever you want to graft on). > Cheers > Robert > -- > Deux choses sont infinies : l'univers et la b?tise humaine ; en ce qui > concerne l'univers, je n'en ai pas acquis la certitude absolue. > > - Albert Einstein