On Saturday, April 27, 2013 07:54:44 =?UTF-8?B?Ikx1w61z?=.Marques 
<[email protected]>@puremagic.com wrote:
> Is this what some of you are asking for?
> 
> bool a = true;             // ok
> bool b = false;            // ok
> bool c = 1;                 // error, no implicit conversion
> bool c = getInt();        // error? ok?
> int x = 42;
> if(x) { ... }                   // ok (doesn't this imply c =
> getInt() ok too?
> if(42) { ... }                 // ok

if conditions and loop conditions automatically insert explicit casts, so

if(foo)

becomes

if(cast(bool)foo)

which makes it so that you can define how a user-defined type will be treated 
when used in a condition and for built-in types completely removes if 
statements and loops from discussions on implicit conversion as there's no 
implicit conversion being used (unless you're arguing for the cast to not be 
inserted for conditions, in which case, implicit conversion _would_ be used).

- Jonathan M Davis

Reply via email to