On Thursday, 13 December 2012 at 14:25:27 UTC, Simen Kjaeraas
wrote:
foo(b); // Cannot implicitly convert byte to bbyte.
I think the way it is now is correct for alias this.. it is kinda
like implicitly casting to a base class. That's correct, but
going to a superclass isn't necessarily right. You might only
want it to be one way. Suppose you had something like this:
struct SafeText {
string text;
alias this text;
}
Safe text should implicitly convert to plain string text, but it
shouldn't go the other way automatically.
A long time ago, when dinosaurs roamed the earth,
walterandrei.pdf[5] suggested that opImplicitCastTo and
opImplicitCastFrom take care of this conversion.
A separate function or facility for implicit cast to might be ok
though.