From: Mats Kindahl Date: August 27 2010 7:03am Subject: Re: [STYLE] use true/false in C++, not TRUE/FALSE List-Archive: http://lists.mysql.com/internals/38035 Message-Id: <4C77632A.1080608@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi Guilhem, I support both proposals. There is no problem with the standard conversions regarding C:s idea of "true" to C++:s idea of "true". It was designed explicitly for this. Just my few cents, Mats Kindahl On 08/26/2010 03:16 PM, Guilhem Bichot wrote: > Hello, > > http://forge.mysql.com/wiki/MySQL_Internals_Coding_Guidelines > says > > "Use TRUE and FALSE instead of true and false in C++ code. This makes > the code more readable and makes it easier to use it later in a C > library, if needed." > > Proposal 1 > ========== > Use true/false, not TRUE/FALSE, for storing in into bool objects, or > into bool function parameters. Do so for new code. Change existing > code only when there's a deeper reason. > > Rationale > ========= > I disagree with "more readable". I find that those capital letters are > so eye-catching that they attract too much the reader's attention, for > example when I read those lines (from 5.1) I pay more attention to > TRUE that to "ref", which is bad: > > if ((*group->item)->walk(&Item::find_item_processor, TRUE, > (uchar *) ref)) > > having->split_sum_func2(thd, ref_pointer_array, all_fields, > &having, TRUE); > > Also, I find it strange: "bool" can take "true" or "false" by design, > why are we forced to use something else? > > Proposal 2 > ========== > > Extend proposal 1 to using true/false for storing into my_bool C > function parameters, and to using bool for storing the my_bool result > of C functions. > > Rationale > ========= > TRUE/FALSE is needed for my_bool (which is char) in C code. > As for calls to C functions from C++, if the function takes a my_bool > parameter, passing true/false is ok, as there would be implicit > conversion from bool to my_bool, true becomes 1 (==TRUE), false > becomes 0 (==FALSE). Storing a my_bool result from the C function into > a bool would also be correct (any non-zero value would become true). > Thus it sounds possible to completely eliminate TRUE/FALSE from C++ code. >