==, is

Steven Schveighoffer schveiguy at yahoo.com
Mon Nov 15 13:02:47 PST 2010


On Mon, 15 Nov 2010 15:40:43 -0500, Ellery Newcomer  
<ellery-newcomer at utulsa.edu> wrote:

> a while ago, I assumed that
>
> e1 += e2
>
> gets rewritten as
>
> e1 = e1 + e2
>
> Yeah. It doesn't. It doesn't even behave the same wrt erroneously typed  
> arguments

I understand the care taken, but the spec gives reasons to believe  
otherwise:

There is opAdd and opAddAssign

There are opEquals and opIn, but no opNotEquals and opNotIn.

If you can override the operators independently, naturally you should not  
expect that one is rewritten, otherwise why have the independent operators?

Likewise, if there is no overload for the opposite, then it must be a  
rewriting function.

'is' is sorta different because you can't override it either way.

-Steve


More information about the Digitalmars-d-learn mailing list