Discussion: Introducing new operators for matrix computation

Bjorn Pettersen bjorn at roguewave.com
Thu Jul 13 18:35:57 EDT 2000


Huaiyu Zhu wrote:
> 
> On Thu, 13 Jul 2000 13:18:37 -0600, Bjorn Pettersen <bjorn at roguewave.com>
> wrote:
> 
> >It seems like you're trying to create a special purpose language here.
> >Ie. I don't see it as general enough to be worth putting into the core
> >unless you can come up with other use cases... Personally, I would much
> >prefer the ability to overload the relational operators (individually,
> >not through __cmp__).
> 
> This is not a call for a special language for matrix only.  But we do need
> enough binary operators to override with.  The additional operators might be
> useful at other places as well.
> 
> In matlab the following operations are all different from each other
> 
> a+b        a.+b
> a-b        a.-b
> a*b        a.*b
> a/b        a./b
> a\b        a.\b
> a^b        a.^b
> 
> What python operators can we override for them all? Just one additional
> symbol for so many new binary operators is a good bargain, IMO.
[snip]

I fully understand your desire to make the syntax for your domain
specific notation as intuitive as possible.  For people who don't know
matlab however, .+ et. al. have no pre-defined meaning. Since + has a
predefined meaning of addition, most people when overloading it will do
"additive" things with it, e.g. concatenating to sequences. Since .+
doesn't have a pre-defined meaning I'm afraid people will override it
with random semantics...

If you want to do matlab syntax, perhaps a better approach would be to
write your own expression parser?

-- bjorn




More information about the Python-list mailing list