Hi --
On Wed, 21 May 2003, Hal E. Fulton wrote:
> Think for a moment about why we have
> the keyword "super" -- it's a way of
> distinguishing between the current
> method and the one in the parent, but
> it's also a convenient shorthand that
> does not depend on the method name.
>
> I once proposed a keyword "prior" that
> would refer to the old definition of a
> method that was being replaced. This
> would make unnecessary the idiom of
> explicitly creating an alias and then
> calling the old method by name.
>
> But Matz replied (I'm paraphrasing)
> that this was a part of a more general
> problem, and that something like Lisp's
> defadvice was the answer.
I don't know about defadvice either, but a thought or two anyway:
'prior' might have a usefulness, but it would not be a drop-in
replacement for what alias currently does (which of course is also
very different from what super does). alias'ing a method makes that
method callable in a general way, so:
class A
def x; end
end
class B
alias :y :x
def z; y; end # 'prior' would be meaningless here
end
I have some instinct that tells me that a method cannot, as a general
matter, "know" that it is replacing an existing method (because it may
or may not be, depending on dynamically evaluated conditions), but I
can't quite think my way through it. Perhaps I'll try to babelfish
thing with Matz's weblog :-)
David
--
David Alan Black
home: dblack / superlink.net
work: blackdav / shu.edu
Web: http://pirate.shu.edu/~blackdav