deprecate boolean evaluation of floating point and character types

Basile B. b2.temp at gmx.com
Mon May 6 10:51:54 UTC 2024


On Wednesday, 1 May 2024 at 10:01:29 UTC, Nick Treleaven wrote:
> On Tuesday, 30 April 2024 at 17:01:42 UTC, Basile B. wrote:
>> Generally there is a strong correlation between default 
>> initialization and boolean evaluation to `false`.
>
> But the meaning of boolean evaluation of a number is to check 
> if it is non-zero. That is well established from C.
>
>> instead of an assertion failure what we should get is rather a 
>> message such as
>>
>>    error, cannot evaluate `f64` to a `bool`
>
> Why break D code that was written with the non-zero test 
> expectation? Why make porting from C harder yet still allow 
> non-zero tests for integers? Wouldn't that be more confusing?

This idea is a preliminary work for something bigger: I'd like to 
propose a DIP for inline variable declarations. For them I have 
the feeling that char.init and {float|double|real}.init would not 
work very well. I'm not 100%s sure.

I'd say that it's not worth discuting this anymore for now.


More information about the dip.ideas mailing list