Add support implicit conversion between types
ilya-stromberg
ilya-stromberg-2009 at yandex.ru
Sat Sep 7 06:19:37 PDT 2013
On Saturday, 7 September 2013 at 13:02:39 UTC, Simen Kjaeraas
wrote:
> It's a bit weird in D though, as operators are instance
> methods, and
> opImplicitRightCast (or opImplicitCastFrom, which is the name
> used in
> discussions before, see WalterAndrei.pdf from back when
> dinosaurs roamed the
> earth) should definitely not be an instance method but a static
> one.
>
> That said, I belive opImplicitCastFrom is The Right Solution™.
> It's explicit,
> it's a bit ugly, but not so much it hurts.
Yes, "opImplicitCastFrom" looks better. I didn't know about
"WalterAndrei.pdf" file. Can you give me a link to the file? It's
intresting to read.
In C# this operator is static:
class Foo {
public Foo(int temp)
{
}
public static implicit operator Foo(int temp) {
return new Foo(temp);
}
}
So, I agree, the "opImplicitCastFrom" should be also static.
More information about the Digitalmars-d
mailing list