Inconsistency increasing
Jarrett Billingsley
kb3ctd2 at yahoo.com
Sun Aug 26 14:35:01 PDT 2007
"DavidL" <Davidl at 126.com> wrote in message
news:op.txn9lnubbag506 at 39eee18d1a25413...
> opAdd_r VS opAdd
> opImpicitCastTo VS opImplicitCastFrom
>
> consider:
> objectA + objectB
>
> objectB get opAdd_r
> objectA get opAdd
>
> what would happen?
This is already defined. See
http://www.digitalmars.com/d/1.0/operatoroverloading.html, Binary Operator
Overloading, example 5. This is ambiguous.
> structB = structA
> structA get opImplicitCastTo and structB get opImplicitCastFrom, what
> would happen?
> both get called? or the one *well* defined by compiler( this kind of
> specification could cause
> many issues imo)
This would probably result in a similar ambiguosity.
> we don't need an OOP style operator overloading
> we need a global operator overloading
If it's well-defined (which it is), OOP-style operator overloading works
just fine. However, notice that D2 is generalizing method calls, so that
"x.f()" and "f(x)" can be semantically equivalent. This might bring global
operator overloading as a side-effect.
More information about the Digitalmars-d
mailing list