On Sat, Apr 3, 2021 at 3:49 AM John <john.r.mo...@gmail.com> wrote:
>
> These are good points.
>
> I would suggest the unary - creates serious readability concerns and
> should only be valid as 0 x -; ~ and unary + raise other
> considerations.  The ~ operator is extremely useful in bitshift and
> bitmask operations, and has an ugly ~x representation as 0 1 - x ^ in
> the same way as unary -x is 0 x - (which is elegant).
>
> Unary can't be assumed from 0 x +, and it seems inelegant to use
> things like ~x -x +x (i.e. without white space)
>

That would mean that unary plus is no longer available to any type
that isn't strictly a number. Python doesn't make mandates like that.

>>> from collections import Counter
>>> c = Counter(a=1, b=2, c=-4)
>>> +c
Counter({'b': 2, 'a': 1})
>>> c
Counter({'b': 2, 'a': 1, 'c': -4})
>>> 0+c
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'Counter'

What's the advantage that you're offering? This is on python-ideas, so
I have to assume that you're proposing a change or enhancement to the
language here.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/FMFPVANZY4XTXSJAYNUY4UTUXPFNINUF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to