[Python-Dev] Re: [Fwd: Discussion: Introducing new operators formatrix computation]

Huaiyu Zhu huaiyu_zhu@yahoo.com
Fri, 14 Jul 2000 16:33:13 -0700 (PDT)

On Sat, 15 Jul 2000, Fredrik Lundh wrote:

> Huaiyu Zhu wrote:
> > Given what's quoted below, would you think . is the best choice?
> if what you're saying means that:
>     >>> 1.+2.
>     3.0
> becomes:
>     >>> 1.+2.
>     Traceback (innermost last):
>       File "<stdin>", line 1, in ?
>     TypeError: __dotadd__ nor __rdotadd__ defined for these operands
> it's clearly not a good choice.
> </F>

To quote from my c.l.py post:

On Fri, 14 Jul 2000 11:38:51 -0600, Bjorn Pettersen <bjorn@roguewave.com>
>Well, this could actually be generally useful, but not with the .+
>syntax (since the dot would interfer with methods on the sequence

My impression from the python-dev list is that this is not the case.  Some
say it is easy to distinguish

a. + b
a .+ b

Some say it is difficult.  But the first is a syntax error anyway. 

The only real danger is 

3. + a
3 .+ a

But in this case pointwise operation does not make sense. 

So I suppose the following rules would resolve all the ambiguities:

Dot binds with preceding number.  Otherwise it binds with following
operator. Otherwise it is a member indicator.  Otherwise it is syntax error.


a.+b    <-- only this is new