Useless expressions [was Re: Undefined behaviour in C]
Marko Rauhamaa
marko at pacujo.net
Mon Mar 28 09:29:21 EDT 2016
BartC <bc at freeuk.com>:
> So no matter how many potentially useful counter-examples you can dig
> up, non-function-call expressions are still going to be highly
> unusual. And suspect.
>
> That's why it's not going to be much loss to disallow them /in that
> form/.
Note that operators are front ends for dunder methods, which can have
side effects. I'm not aware of such an example in Python, but C++
notoriously uses operator overloading in its common I/O idioms:
cout << "Hello world!" << endl;
It turns out that I am currently creating something exciting in Python
that "abuses" operators similarly, although without side effects -- I
hope to be able to present my results here soonish. So I would be
careful not to throw the baby away with the bathwater.
There was a time when recursion was viewed with great suspicion, and
nested if/else constructs were considered playing with fire. You are
clearly getting similar allergic reactions from Python's elegant degrees
of freedom. And all the while Java, C# and even C++ are painfully trying
to get what Python has had since the beginning.
Marko
More information about the Python-list
mailing list