Alias_method problem

I thought about it but it was inconvenient. The key is that
one has to always remember this side effect in order not to make the mistake
no matter what one would do.

Thanks

-Ted

···

From POP3 Tue Jul 16 16:50:55 EDT 2002
Date: Wed, 17 Jul 2002 05:49:40 +0900
Posted: Tue, 16 Jul 2002 13:51:15 -0700
From: Joel VanderWerf vjoel@PATH.Berkeley.EDU
Subject: Re: alias_method problem
To: ruby-talk@ruby-lang.org (ruby-talk ML)
X-ML-Name: ruby-talk
X-Mail-Count: 44659
X-MLServer: fml [fml 3.0pl#17]; post only (anyone can post)
X-ML-Info: If you have a question, send e-mail with the body
“help” (without quotes) to the address ruby-talk-ctl@ruby-lang.org;
help=mailto:ruby-talk-ctl@ruby-lang.org?body=help
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529
X-Accept-Language: en-us, en
X-Virus-Scanned: by amavisd-milter (http://amavis.org/)
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit

mengx@nielsenmedia.com wrote:

But if for some reason the class is reloaded, The “oldone” will
point to the “newone” that is defined as above(calling the “oldone”)
instead of the originally defined one.
Calling “newone” after the reloading ends up with stack overflow.

I assume this had been brought up before. Any fix or workaround?

It was discussed starting at:
http://ruby-talk.org/34131

What about putting the alias operation in a different file from the rest
of the class def?

=== A-alias.rb ===

class A
alias …
end

=== A.rb ===

require “A-alias”

class A
def …
end
end

============

This way, you can always reload A.rb without re-aliasing.