On Thursday, 11 July 2013 at 18:31:50 UTC, Jesse Phillips wrote:
I forgot to mention that most of the casting you were doing
doesn't do what you think it would.
...
This doesn't make an Option!int castable to a Maybe!int, they
are still distinct types:
...
struct Test1
{
int n;
}
struct Test2
{
string s;
Test1 t;
alias t this;
}
void main()
{
auto t1 = Test1();
auto t2 = cast(Test2)t1; //Error
}
It seems you're right. That's disappointing. TDPL talks about
alias this in terms of subtyping, but doesn't the above code show
that this is not true subtyping?