Improved multimethods.py
David Mertz
mertz at gnosis.cx
Sun Jan 5 02:38:50 EST 2003
"Samuele Pedroni" <pedronis at bluewin.ch> wrote previously:
|I think a multi-argument generalization of super (similar also to
|Cecil resend), would be the most flexible, pythonic solution.
I'm actually still not convinced that using this is a good idea in
practice. But then, I've come to believe that 'super()' cannot be
trusted either (even though I am starting to appreciate the elegance of
C3 linearization) *wink*. Even though I've never really been a C++
programmer, I sense a virtue in explicitly naming the superclass you
want to call.
Nonetheless, I don't want to disappoint Sam and Paul, so I've added this
functionality to:
http://www.gnosis.cx/secret/multimethods.py
I decided to call the capability 'dispatch.next_method()' rather than
'multi_super()' that I had toyed with. This naming follows Dylan, and
would seem to serve the same purpose.
There are some more improvements too. I gave an example of using
(simulated) positional and keyword arguments in multimethods. I made
lexicographic_mro() the default linearization.
One thing I don't yet have is a linearization that matches Dylan, i.e.
rejecting ambiguities. If anyone feels like contributing that, I'd be
thankful.
Yours, David...
--
mertz@ | The specter of free information is haunting the `Net! All the
gnosis | powers of IP- and crypto-tyranny have entered into an unholy
.cx | alliance...ideas have nothing to lose but their chains. Unite
| against "intellectual property" and anti-privacy regimes!
-------------------------------------------------------------------------
More information about the Python-list
mailing list