Can someone explain why opCast is so limited?

Stewart Gordon smjg_1998 at yahoo.com
Mon Sep 10 04:54:35 PDT 2007


"Robert Fraser" <fraserofthenight at gmail.com> wrote in message 
news:fbpmc1$9gb$1 at digitalmars.com...
<snip>
> Yes, that will be possible. alter's presentation suggested there would be:
>
> opImplicitCastTo
> opImplicitCastFrom
> opExplicitCastTo (what "opCast" does right now)
> opExplicitCastFrom
>
> All of which will be overloadable on different types (the slides
> had them overloadable on return type, but Walter mentioned that he
> might use out params instead).  The opExplicitCasts were not
> mentioned in his slides, but he did say something that suggested
> they would be there.

So:
(a) programmer-defined implicit casts are going to be supported?  I thought 
this had been decided against because of the resulting sheer difficulty of 
determining what gets converted to what.
(b) it's going to be possible to define two different conversions from type 
X to type Y, one implicit and the other explicit???
(c) opImplicitCastTo and opExplicitCastTo are going to be special function 
names that allow return type overloading?

Please see my proposal:
http://www.digitalmars.com/d/archives/digitalmars/D/20540.html#N20712

It's similar to (c), but reuses the keyword 'cast' as a placeholder for a 
function name.

Stewart. 



More information about the Digitalmars-d-learn mailing list