On Sunday, 14 October 2012 at 06:22:03 UTC, Maxim Fomin wrote:
On Saturday, 13 October 2012 at 17:01:27 UTC, Tommi wrote:
Another way to describe my reasoning...
According to TDPL, if var is a variable of a user-defined
type, then:
++var
gets rewritten as:
var.opUnary!"++"()
Not always. If user-defined type has an alias this to integer
member, than something different would happen.
Yeah, I wasn't specific enough with that example.
It would be also interesting to see, how operation ++T would
differ because somebody imported module with opUnary method.
Because opUnary suits better than alias this, dmd will issue
call to that function, it it see its declaration.
Actually, it seems that alias this has precedence over UFCS. So,
a free function opUnary wouldn't ever suit better than an actual
method opUnary of the thing referred to by that alias this.