www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - implicit conversion of complex to real

reply "Ilya Zaitseff" <sark7 mail333.com> writes:
Why such conversion is allowed? I think it is a bug.

Moreover, it prevents overloading.
At least, give to conversion to complex types more priority.

<cfloat_sqrt.d>
import std.math;

void foo(float a) {}
void foo(creal a) {}

void main()
{
   cfloat a;
   cfloat b = sqrt(a);
}

cfloat_sqrt.d(9): function std.math.sqrt overloads float(float) and  
creal(creal z) both match argument list for sqrt
Nov 18 2004
parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Ilya Zaitseff wrote:
 Why such conversion is allowed? I think it is a bug.
 
 Moreover, it prevents overloading.
 At least, give to conversion to complex types more priority.
There's no such thing as better or worse overloading matches in D. There are exact matches, implicit conversion matches and non-matches. We need to turn this into a non-match. Stewart.
Nov 19 2004