[Numpy-discussion] (a and b) != (b and a) ?

Andrew P. Lentvorski bsder at mail.allcaps.org
Wed Jun 12 23:12:02 EDT 2002


On Wed, 12 Jun 2002, Scott Gilbert wrote:
> C++ has overloadable && and || operators, but overloading them is frowned
> on by many.  C++ has the advantage over Python in that it knows the actual
> types at compile time.

Actually, overloading && and || isn't just frowned upon in C++, it's
effectively banned.  The reason is that it replaces short-circuit
semantics with function call semantics and screws up the standard idioms
(if ((a != NULL) && (*a == "a")) { ... } ).  See "Effective C++" by Scott
Meyers.  As far as I know, *none* of the C++ literati hold the opposing
view.

-a






More information about the NumPy-Discussion mailing list