merits of Lisp vs Python

Paul Rubin http
Sun Dec 10 00:16:02 EST 2006


Steven D'Aprano <steve at REMOVE.THIS.cybersource.com.au> writes:
> > Or (defmethod name :after ..)?
> I don't even know what that means. Would you like to translate?

This is something that I've wished Python had.  If I try to describe
it I'll probably get it wrong.  But basically say Foo is a class with
multiple superclasses.  The superclasses each define a "name" method
and Foo itself may also define a "name" method.  When you call
Foo.name() you want that to invoke both Foo's name method and the
superclass methods.  In Python you have to do grotty things like
super(Bar,self).name() in the Foo.name() to make this happen by hand,
and you have to keep tweaking that as you add and remove superclasses.
In Lisp, you can set it up so that the multiple "name" calls happen
automatically.  The :before, :after, and :around keywords let you say
what order you want the calls to happen in.  You'd use :before for
setup actions, :after for cleanup actions, and just plain defmethod
for the stuff that is supposed to happen in between.



More information about the Python-list mailing list