On Thu, Jul 15, 2010 at 1:50 PM, Jan Dubois <jand@activestate.com> wrote:
> Once you implement magic/overloads that violate the underlying algebraic
> relationships in your overloaded operators you will end up in a world
> of pain. E.g. the following expressions should always be true:
>
> ($a + $b) == ($b + $a)
> ($a < $b) == ($b <= $a)
> "$a" eq $a
> ($a eq $b) && ($b eq $c) == ($a eq $c)
FWIW, while I'm otherwise in agreement, I wouldn't want to impute
parameter reordering to operators like + because of their common
overloading to mean string concatenation.
"X" + "Y" == "Y" + "X"
This isn't reasonably true if these strings are some kind of object
that does concatenation and == is maybe something other than numeric
equality.
Josh
Thread Previous
|
Thread Next