DMD 0.177 release
Andrei Alexandrescu (See Website for Email)
SeeWebsiteForEmail at erdani.org
Wed Dec 13 18:36:04 PST 2006
Walter Bright wrote:
> opAssign has 3 externally visible characteristics:
>
> 1) the parameter
> 2) the 'this' pointer
> 3) the return value
>
> Your proposal mixes up 2 and 3. opAssign works like:
>
> a = b
> becomes:
> a.opAssign(b)
>
> The return value is not assigned to a, it is the value of the expression
> (a = b). Mixing up the return value and the assignment to a will cause
> problems, as the two are different things, and should be independent.
That makes me wonder - if a = b is used without picking up its result
(the usual case), and if opAssign() returns an S, will the compiler
optimize away the extra copy at zero cost?
What I think happens is that the function will take a pointer to the
destination which is zero, so a comparison will be made. But perhaps the
optimizer will take care of eliminating that?
Andrei
More information about the Digitalmars-d-announce
mailing list