From: Dave Thomas Date: 2002-02-18T16:17:35+09:00 Subject: Re: alias danger Joel VanderWerf writes: > 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: That's always been an issue which has worried me. An alternative suggestion: have two new keywords, 'redef' or 'prior' module ExtraLong redef length prior * 2 end end class String include ExtraLong end "cat".length #=> 6 redef is a method definition, like def, but it keeps the prior version lying around (in the same way alias does). The 'prior' keyword can then be used to invoke that previous definition. Like super, prior with no parameters would pass on its caller's parameters, and prior with parameters would just pass them. Is the problem really worth adding two new keywords to the language? Personally, I think it is. The current alias/def scheme is a bit of a mess. As you point out, it isn't safe. It also isn't great at imparting intent -- is the alias there to give the method two names (alias size length) or as preparation for redefining the method? Would the feature be used? Look through the libraries and you'll find method redefinitions galore, so I think the answer is yes. Matz? Would this stand a chance as an RCR? Dave