Should you be able to initialize a float with a char?

John Colvin john.loughran.colvin at gmail.com
Thu May 19 18:38:00 UTC 2022


On Thursday, 19 May 2022 at 18:20:26 UTC, Walter Bright wrote:
> On 5/19/2022 7:33 AM, Steven Schveighoffer wrote:
>> I hope we are not depending on the type system to the degree 
>> where a bool must be an integer in order to have this kind of 
>> optimization.
>
>
> Does that mean you prefer:
>
>     a = 3 + cast(int)(b < c) * 5;
>
> ? If so, I don't see what is gained by that.

a = 3 + int(b < c) * 5;

avoids forcing it with an explicit cast, lower risk of writing a 
bug (or creating one later in a refactor).


More information about the Digitalmars-d mailing list