Should alias this support implicit construction in function calls and return statements?
Adam D. Ruppe
destructionator at gmail.com
Thu Dec 13 06:38:29 PST 2012
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.
More information about the Digitalmars-d
mailing list