Why are opCall's not implicitely assignable?

Jarrett Billingsley kb3ctd2 at yahoo.com
Fri Sep 22 07:02:59 PDT 2006


"Karen Lanrap" <karen at digitaldaemon.com> wrote in message 
news:Xns984698A00AE21digitaldaemoncom at 63.105.9.61...

> If you then say it is not an overloading of the assignment operator
> you have to give a reason, why it differs from overloading the
> assignment operator.
>
> I do not see any difference. So please explain. I am posting in the
> learn group with the aim to understand the language. If I would have
> a clear opinion on this matter I would post in the main D group.

When I talk about operator overloading, I mean in the sense of classes. 
Have a look at the Operator Overloading section of the spec.  opAdd, opSub, 
etc.  that kind of operator overloading.

I think you're taking the idea of "overloading" a bit literally.  When we 
say that "f = 4" is just syntactic sugar for "f(4)", I suppose that yes, in 
a very literal sense of the word, the assignment operator is overloaded to 
mean "function call" in this case.  However, it's not user defined, it's 
part of the language.  So I wouldn't really call it "overloaded."  It's the 
same thing as anything with multiple meanings in the language -- would you 
call the tilde (~) operator "overloaded" because it means both bitwise 
complement and array concatenation?

Since the user cannot control what the assignment operator means, it is not 
overloadable, and by that, I mean you cannot create an opAssign to change 
its semantics. 





More information about the Digitalmars-d-learn mailing list