On Sun, Jun 9, 2013 at 3:37 PM, Zeev Suraski <z...@zend.com> wrote: > What I meant by cumulativity in that context is really commutativity J > Fixed (and also added transitivity). > > > > In other words, operands that are commutative in PHP (like addition, > multiplication, etc.) – one should not overload for domains where they’re > not commutative. > > > > Zeev >
Why? For example matrix multiplication is not commutative, but I would still consider writing $matrixA * $matrixB a valid application of overloading. Non-commutative multiplication operations aren't uncommon (that's why a mathematical ring only requires the addition operator to be commutative). The same also applies the other way around: For example PHP's default + operator is *not* commutative (when used on arrays) and both + and * are non-associative and non-distributive (floating point arithmetic), but you'd probably still expect those properties from an overloaded +/- operator. That's why I'm not sure it makes sense to have "too strict" definitions for what is a valid overload and what isn't. I think "limited to cases where there are clear definitions to the behavior of all overloaded operators" and "should be for mathematical use cases only" are enough as guidelines :) Thanks, Nikita