On 8/7/2011 10:43 AM, bearophile wrote:
and there's that cast to float he overlooked, sabotaging his upgrade. Even
worse, suppose the type of f or d or both is changed to some user defined type,
like BigFloat? That cast is just going to *cause* a bug, not fix it.

Requiring the programmer to load up on casts is not necessarily making the code
less "bug-prone".

Thank you for your good explanation.

I presume this doesn't improve the situation a lot:

float f;
double d;
...
f = cast(f.typeof)d;

That can improve things for the case where f is available, but that isn't always the case (such as when passing d to a function that takes a float parameter).

Reply via email to