[Python-ideas] [Python-ideos] Dedicated overloadable boolean operators

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Nov 24 17:45:45 EST 2015


MRAB wrote:

> That still doesn't deal with the issue of what should happen if the
> order is reversed, e.g. "numpy_array and simple_bool" vs "simple_bool
> and numpy_array", where "numpy_array" has the non-shortcircuiting
> behaviour but "simple_bool" hasn't.

That's true.

I guess the only solution that really works properly is
to have a second set of operators, or some way of flagging
that you're using non-short-circuiting semantics.

There's one language I've seen -- I think it was Eiffel,
or maybe Ada -- that had two sets of boolean operators.
But it was kind of the other way around: 'and' and 'or'
were non-short-circuiting, and to get short-circuiting
you had to say 'and then' or 'or else'.

-- 
Greg


More information about the Python-ideas mailing list