Will uniform function call syntax apply to operator overloads?
Simen kjaeraas
simen.kjaras at gmail.com
Tue Oct 12 17:32:11 PDT 2010
Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> That would depend on what order it did things. If it replaced a.func()
> with
> func(a) before it replaced a + b with a.opBinary!"+"(b), then it
> wouldn't be
> more work at all. It would just naturally not work. If, on the other
> hand, the
> overloaded operators were replaced first, then it could turn
> a.opBinary!"+"(b)
> into opBinary!"+"(a, b).
True. I thought of it as a single step that does both, and repeatedly
if necessary.
> Personally, I do _not_ think that overloaded operators should work with
> uniform
> function syntax, if for no other reason than because it doesn't actually
> look
> like the uniform function syntax does. There is no . operator directly
> involved.
> And I don't see any real value in overloaded operators which aren't part
> of the
> type. Unlike C++, I don't think that we have any operators where having
> an
> overloaded operator function be a member function is a problem (the
> classic
> operators with that problem being >> and <<).
Yeah, I also think it should at least be discouraged. I cannot see any
situations wherein allowing it would bring significant enough advantages
to warrant its use. That said, I am willing to accept there may be such
situations, and perhaps even that they should be allowed.
--
Simen
More information about the Digitalmars-d
mailing list