lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: [lmi] Avoiding PETE's overloaded operator==()


From: Vadim Zeitlin
Subject: Re[2]: [lmi] Avoiding PETE's overloaded operator==()
Date: Wed, 9 Jun 2010 12:03:30 +0200

On Sat, 05 Jun 2010 15:12:14 +0000 Greg Chicares <address@hidden> wrote:

GC> IMO, my example doesn't demonstrate a PETE defect. For these two vectors:
GC>   v0 {1, 2, 3}
GC>   v1 {1, 2, 4}
GC> if you applied APL's equality operator, you'd get this vector:
GC>   1 1 0
GC> To determine whether all elements are equal, you'd AND-reduce that to a
GC> scalar, which would be zero. PETE doesn't seem to have reduction, but its
GC> where() function would be useful with its member-by-member equality 
operator.

 FWIW I disagree because IMNSHO the equality operator in C++ has a
well-defined signature and in particular must return bool. I don't say it's
necessarily the best convention (as often, I think Perl 6 gets this best with
its hyper-operators) and it's definitely not the only possible one but it's
so well-ingrained in a psyche of C++ programmers that calling anything that
doesn't conform to this signature "operator==()" is just not a good idea.
PETE should have called it Compare() or something else but definitely not
hijack the equality operator for this.

 Forcing you to write std::operator==() is just one consequence of this bad
decision but it can result in other surprises.

 Regards,
VZ

reply via email to

[Prev in Thread] Current Thread [Next in Thread]