Why are opCall's not implicitely assignable?

Jarrett Billingsley kb3ctd2 at yahoo.com
Thu Sep 21 19:54:03 PDT 2006


"Karen Lanrap" <karen at digitaldaemon.com> wrote in message 
news:Xns9846572EEDA8digitaldaemoncom at 63.105.9.61...
> Jarrett Billingsley wrote:
>
>> since assignment can't be overloaded, it complains.
>
> Assignments are overloadable.

Sorry, I meant overloading as in operator overloading.  You can't overload 
opAssign in a class.

> import std.stdio;
> int f(int p)
> {
>  return 2*p;
> }
> real f(real p)
> {
>  return 3.0*p;
> }
>
> void main()
> {
>  auto i=f=2;
>  auto r=f=2.0;
>  writefln( i, r);
> }

This is just function overloading - keep in mind that you're not _really_ 
assigning anything to f, it's just sugar. 





More information about the Digitalmars-d-learn mailing list