Discussion: new operators for numerical computation

Neel Krishnaswami neelk at brick.cswv.com
Sat Jul 22 09:23:50 EDT 2000


Aahz Maruch <aahz at netcom.com> wrote:
> In article <slrn8nevfr.d8.bmcd at ripley.sulaco.net>,
> Ben Caradoc-Davies <bmcd at es.co.nz> wrote:
> >
> >The fact that APL has been mentioned in this thread is a bad, *bad* sign.
> 
> Yeah, that's my feeling, too.  It's not entirely clear to me why we
> can't use some kind of string-based expression mechanism instead of
> adding all this at the language level.  Python's brilliance is its
> *clean* syntax.  Why are we mucking with the core language for this?

We do need to muck with the language to fix this, but the answer is
NOT to add syntax, but to remove the type/class dichotomy. Then it
will be possible to do something to fix the __mul__/__rmul__ thing so
it's actually usable. 

My proposal would be to replace it with encapsulated multimethods,
because that's the best way of solving the binary method problem in an
OO language. This is really the key problem people face: Elementwise
and matrixwise multiplication are easy to implement, but doing it so
that Python calls the right one at the right time, in a way that you
can still extend the system with new subclasses, is hard.


Neel



More information about the Python-list mailing list