DIP 52 - Implicit conversions

bearophile bearophileHUGS at lycos.com
Wed Dec 11 07:28:50 PST 2013


Simen Kjærås:

> http://wiki.dlang.org/DIP52

> However, given that this code compiles and works perfectly:
> 
> void baz() {
>    import std.typecons;
>    Tuple!(int, int) a;
>    Tuple!(int, "x", int, "y") b;
>    a = b; // Implicit conversion to less specialized type.
>    b = a; // Implicit conversion to more specialized type.

I think "b = a;" is an accepts-invalid bug.


> void foo(TaggedUnion!(float, string, int, MyStruct) arg) {}

Do you mean Algebraic?

Regarding the topic of implicit conversions, I propose to warn 
and then deprecate and then disallow the following two implicit 
casts, that only cause confusion, and are of no real utility:

enum Foo { A, B }
void main() {
     enum int i1 = 1;
     bool b1 = i1; // deprecate
     int i2 = Foo.A; // deprecate
}

Bye,
bearophile


More information about the Digitalmars-d mailing list