<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Aug 3, 2018 at 6:05 PM, Benedikt Werner <span dir="ltr"><<a href="mailto:1benediktwerner@gmail.com" target="_blank">1benediktwerner@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
There was a proposal to allow overloading boolean operators in Pep-335 [2], but that PEP was rejected for a variety of very good reasons. I think none of those reasons (besides the conversation fizzling out) apply to my proposal.<br>
</blockquote></span>
Maybe I am missing something, but I don't really see how this idea solves the problems that lead to PEP 335 getting rejected. As far as I understand it the main reason for the rejection was that this would decrease performance for all boolean operations which are extremely common where as the need for overriding these operators is rather rare. (See the rejection email here: <a href="https://mail.python.org/pipermail/python-dev/2012-March/117510.html" rel="noreferrer" target="_blank">https://mail.python.org/piperm<wbr>ail/python-dev/2012-March/<wbr>117510.html</a>)<br>
<br>
As I see it this proposal only proposes a different syntax and doesn't solve this problem.<br>
<br>
The only real solution for this would be a new set of operators but I agree with Chris that overriding the bitwise operators is good enough for most cases and a new set of operators really is a bit over the top just for this. I especially dislike using || and && as they are prominently used in other programming languages and this would be extremely confusing for newcomers from those languages. Also if the syntax isn't clear and consice I feel it doesn't really add any value as the main point of operator overloading is to make code easy to read and understand. This really only would be the case if we could overload the boolean operators. Otherweise I think using a function or overloading the bitwise ops is the best solution.<br><br></blockquote><div><br></div><div>The proposal is for new operators. The operators would be "bNOT", "bAND", "bOR", and "bXOR". They would be completely independent of the existing "not", "and", and "or" operators, operating purely on boolean values. It would be possible to overload these operators.<br></div></div></div></div>