From: Guilhem Bichot Date: August 26 2010 1:16pm Subject: [STYLE] use true/false in C++, not TRUE/FALSE List-Archive: http://lists.mysql.com/internals/38031 Message-Id: <4C76693B.4030706@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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. -- Mr. Guilhem Bichot Oracle / MySQL / Optimizer team, Lead Software Engineer Bordeaux, France www.oracle.com / www.mysql.com