A possible solution for the opIndexXxxAssign morass
Robert Jacques
sandford at jhu.edu
Wed Oct 14 07:39:27 PDT 2009
On Wed, 14 Oct 2009 10:31:06 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Don wrote:
>> Well timed. I just wrote this operator overloading proposal, part 1.
>> http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP7
>> I concentrated on getting the use cases established.
>
> I'm not sure multiplication is generally commutative (e.g. in linear
> algebra it isn't). So why should a * x be interchangeable with x * a?
>
> Also, the much-discussed identity:
>
> x @= y <--> x = x @ y
>
> is difficult to enforce statically in practice. I think some types would
> want to define both to achieve good efficiency. It would be hard for the
> compiler to render one unnecessary or to prove that the two are
> equivalent.
>
>
> Andrei
When a is a scaler, a * x <=> x * a generally holds. It's only when
something isn't a scaler, i.e. x1 * x2 != x2 * x1, that community(?)
doesn't hold.
More information about the Digitalmars-d
mailing list