[PEP draft 2] Adding new math operators

Huaiyu Zhu hzhu at localhost.localdomain
Wed Aug 9 18:37:14 EDT 2000


On 09 Aug 2000 23:59:11 +0200, Bernhard Herzog <herzog at online.de> wrote:

[ nice explanation about distinction between tokenizer and parser ]

>In the part you didn't quote:
>
>  You could probably work around it by also allowing ~+ and ~- to be
>  used as unary operators, but that seems awkward.
>
>I was trying to say that to work around this, you have to extend the
>grammar and compile the unary operators ~+ and ~- as if they mean ~ +
>and ~ - respectively.

I don't quite follow here.  Isn't this the behavior of current Python?  The
proposal does not introduce unary operators ~+ ~-.  In current Python:

>>> +1
1
>>> ~+1
-2
>>> -~+1
2
>>> ~-~+1
-3


>Since it can be worked around, this collision of ~- and ~ - is not a
>showstopper, but the workaround seems ugly to me.

Maybe you could explain more the nature of work around needed here.


>Well, I kind of like this orthogonality of objectwise and elementwise
>operations and the way it extends to integers and bitwise operations. My
>main gripe with the PEP was that it claims that bitwise operations are
>less fundamental than 'math' which in context probably meant
>matrix-operations or, broader, arithmetic.
[snip]

Thanks for these comments.  I'll reword these paragraphs later. 

Huaiyu



More information about the Python-list mailing list