|
From: | Paul Eggert |
Subject: | Re: master 31544bc: Don’t convert pointer to bool |
Date: | Sat, 20 Mar 2021 10:01:20 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 |
On 3/20/21 7:05 AM, Stefan Monnier wrote:
Is it right to complain or is that a bug in that tool? To my naive intuition, it looks wrong since conversion to bool is standard practice when doing `if (ptr) ...`.
'bool b = ptr;' does not work in C89, and can be tricky in C++ as witness the now-deprecated "safe bool idiom", so there is some style caution here. Also, in my experience 'bool b = ptr;' is more likely to be a typo.
Since Emacs assumes C99-or-later this is just a style thing. Still, on the whole it seems that the "!!" is a win as it is obvious, consumes little room, and makes the unusual conversion clearer to the reader.
[Prev in Thread] | Current Thread | [Next in Thread] |