From: Joel VanderWerf Date: 2002-02-18T15:50:38+09:00 Subject: alias danger A recent (and helpful) suggestion reminded me of the use of alias in a library module to extend its functionality. You do "alias oldmeth meth" and then redefine meth to do something plus call oldmeth. But now I remember why that makes me itch. It's tempting to think of this alias-and-redefine as an operation that is insulated from the rest of the world, but the binding effect of alias is, of course, not local. Unless you choose a very obscure name for you alias, you run the risk of a stack overflow: module M def foo p "foo" end end class C; include M; end c = C.new module M alias oldfoo foo def foo p "foo1" oldfoo end end c.foo # ==> "foo1" # "foo" module M alias oldfoo foo def foo p "foo2" oldfoo end end c.foo # SystemStackError Isn't there some way (perhaps in 1.7?) of getting a copy of M's implementation of foo as a Proc and redefining foo in terms of a closure that refers to this proc? That way, instead of using alias, you'd be able to use a local binding that couldn't affect anyone else. -- Joel VanderWerf California PATH, UC Berkeley mailto:vjoel@path.berkeley.edu Ph. (510) 231-9446 http://www.path.berkeley.edu FAX (510) 231-9512