A request: templated opCast() signature for class/struct

pragma ericanderton at yahoo.com
Sun Feb 18 18:31:24 PST 2007


Walter Bright wrote:
> Pragma wrote:
>> The problem, for the uninitiated, is that D cannot overload by return 
>> type.
> 
> I think I understand the problem, and what you're trying to do. The 
> problem is that T opCast(T)() wouldn't operate like anything else in D, 
> it would be a total hack. I don't know what the right answer is here, 
> we'll just have to work on it.

Thanks for the reply.  I understand completely - if there's a better way 
to implement multiple opCast() overloads, without introducing kludges, 
I'm all for it. :)

After reading some of the replies here, it seems that you and Andrei 
have this ball rolling already.  Frankly, I'm just glad that the 
opCast() issue, overall, is getting some attention.

 >
 > There are currently no user defined implicit casts, though Andrei has
 > suggested adding them with something like opImplicitCast().

It's not a must, but it would certainly help with transparency in a 
bunch of places.  Properly implemented, it would be quite a powerful 
feature.



More information about the Digitalmars-d mailing list