From: Ken Bloom Date: 2006-09-10T12:50:09+09:00 Subject: Re: [CHALLENGE] better alias_method On Sat, 09 Sep 2006 00:20:51 +0900, ara.t.howard wrote: > On Fri, 8 Sep 2006, Ken Bloom wrote: > >> On Fri, 08 Sep 2006 14:34:39 +0900, ara.t.howard wrote: >> >>> i've been wanting a better alias_method for quite some time. essentially i'd >>> like a way out of the trap where executing >>> >>> alias_method '__fubar__', 'fubar' >>> >>> goes haywire when __fubar__ already exists. we've all seen it happen before. >>> >>> anyhow. the interface it'd like would be >> >> It would be nice to have this built in to the language -- a way to blur the >> difference between overriding an inherited method and overriding a method >> defined on the current class, so that `super' would call whatever the >> previous version of the was. >> >> Try this idea on for size. I wrote it a few days ago. Look at the unit >> tests at the end to see how it's intended to be used. I think a little >> syntactic sugar would be nice, but it gets the job done. > > the show stopper for me is the fact that define_method cannot define methods > that take blocks - so your approach loses them during the alias process. > > i remember that define_method will soon have the ability to define methods > that take blocks do you know if that's in 1.8.5 or the 1.9 branch? Having established that 1.9 has this feature, my #override method (and also Facets' #wrap_method should Just Work (TM) in 1.9 with defining methods that take blocks. --Ken -- Ken Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/