D2 status interim report ?

Simen Kjaeraas simen.kjaras at gmail.com
Mon Jun 23 11:00:43 PDT 2008


Extrawurst <spam at extrawurst.org> wrote:

> Walter Bright schrieb:
>> Extrawurst wrote:
>>> Hey Walter,
>>> this is just a list of changes which were originally planned to be  
>>> integrated into D2.0 according to the slides you and Andrei presented  
>>> on DConference '07. So please give us a comment on what perhaps has  
>>> changed or when certain things are going to be addressed.
>>> A little insight on your roadmap would be great.
>>>
>>> (1) STRUCT opImplicitCastTo/From (p.21)
>>> ---------------------------------
>>> How do you want to solve the problem of overloading by return value  
>>> which would be necessary to solve something like the example in the  
>>> slides (p.21):
>>>
>>>    struct S{
>>>        int opImplicitCastTo(){...}
>>>        float opImplicitCastTo(){...}
>>>    }
>>
>> Still planning on it.
>
> So does it mean we gonna get overloading on different return types ?


I wouldn't bet on it. This is already possible:



struct S
{
	void opCastTo(ref int result) {}
	void opCastTo(ref float result) {}
}

int i;
float f;
S s;

s.opCastTo(i);
s.opCastTo(f);



Add syntactic sugar to taste, inform the compiler that opImplicitCastTo is  
a special function, and voilà!

-- Simen



More information about the Digitalmars-d mailing list