On Wednesday, June 20, 2018 08:16:21 Mike Parker via Digitalmars-d wrote: > This is the feedback thread for the first round of Community > Review for DIP 1015, "Deprecation and removal of implicit > conversion from integer and character literals to bool": > > https://github.com/dlang/DIPs/blob/7c2c39243d0d747191f05fb08f87e1ebcb575d8 > 4/DIPs/DIP1015.md > > All review-related feedback on and discussion of the DIP should > occur in this thread. The review period will end at 11:59 PM ET > on July 4, or when I make a post declaring it complete. > > At the end of Round 1, if further review is deemed necessary, the > DIP will be scheduled for another round. Otherwise, it will be > queued for the Final Review and Formal Assessment by the language > maintainers. > > Please familiarize yourself with the documentation for the > Community Review before participating. > > https://github.com/dlang/DIPs/blob/master/PROCEDURE.md#community-review > > Thanks in advance to all who participate.
I think that this is a fantastic idea and that experience has shown that on the whole, the implicit conversion to bool causes far more bugs than it fixes and that the annoyance that the extra explicit casts would cause do not outweigh how error-prone it is for most programmers. So, I'm very much behind this. The only improvement I can think of is what Steven pointed out about conditionals. Technically, conditionals are implicit, explicit casts (in that the compiler inserts an explicit cast for the programmer). So, something like while(1) is lowered to while(cast(bool)1) and does not actually rely on implicit conversions. That's why something like if(auto value = key in aa) works, whereas bool present = key in aa; doesn't. However, that's not clear to everyone, and so the DIP should be clear that it does not affect conditionals, since in those cases, the compiler inserts an explicit casts. The DIP just puts integer and character literals in the same boat as something like string literals in that if("foo") compiles just fine, whereas bool b = "foo"; does not. - Jonathan M Davis