List:Internals« Previous MessageNext Message »
From:Roy Lyseng Date:August 26 2010 1:32pm
Subject:Re: [STYLE] use true/false in C++, not TRUE/FALSE
View as plain text  
Hi Guilhem,

I definitely agree, looking at "true" and "false" is much nicer. And when there 
is a standard, why not follow it?

Thanks,
Roy

On 26.08.10 15.16, 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.
>

Thread
[STYLE] use true/false in C++, not TRUE/FALSEGuilhem Bichot26 Aug
  • Re: [STYLE] use true/false in C++, not TRUE/FALSERoy Lyseng26 Aug
  • Re: [STYLE] use true/false in C++, not TRUE/FALSEMARK CALLAGHAN26 Aug
    • Re: [STYLE] use true/false in C++, not TRUE/FALSEGuilhem Bichot31 Aug
      • Re: [STYLE] use true/false in C++, not TRUE/FALSEMARK CALLAGHAN31 Aug
        • Re: [STYLE] use true/false in C++, not TRUE/FALSEGuilhem Bichot31 Aug
          • Re: [STYLE] use true/false in C++, not TRUE/FALSEJay Pipes31 Aug
            • Re: [STYLE] use true/false in C++, not TRUE/FALSEDavi Arnaut31 Aug
              • Re: [STYLE] use true/false in C++, not TRUE/FALSEJay Pipes31 Aug
                • Re: [STYLE] use true/false in C++, not TRUE/FALSEDavi Arnaut31 Aug
                  • Re: [STYLE] use true/false in C++, not TRUE/FALSEMARK CALLAGHAN31 Aug
                    • Re: [STYLE] use true/false in C++, not TRUE/FALSEDavi Arnaut31 Aug
                      • Re: [STYLE] use true/false in C++, not TRUE/FALSEMARK CALLAGHAN31 Aug
                        • Re: [STYLE] use true/false in C++, not TRUE/FALSERoy Lyseng31 Aug
                          • Re: [STYLE] use true/false in C++, not TRUE/FALSEMARK CALLAGHAN31 Aug
                            • Re: [STYLE] use true/false in C++, not TRUE/FALSEMichael Widenius8 Sep
                              • Re: [STYLE] use true/false in C++, not TRUE/FALSEJay Pipes8 Sep
                          • RE: [STYLE] use true/false in C++, not TRUE/FALSEVladislav Vaintroub31 Aug
                            • Re: [STYLE] use true/false in C++, not TRUE/FALSERoy Lyseng31 Aug
                            • Re: [STYLE] use true/false in C++, not TRUE/FALSEDavi Arnaut31 Aug
                              • Re: [STYLE] use true/false in C++, not TRUE/FALSEMichael Widenius8 Sep
                                • Re: [STYLE] use true/false in C++, not TRUE/FALSEDavi Arnaut8 Sep
                                  • RE: [STYLE] use true/false in C++, not TRUE/FALSEVladislav Vaintroub8 Sep
                        • Re: [STYLE] use true/false in C++, not TRUE/FALSEMichael Widenius8 Sep
                      • Re: [STYLE] use true/false in C++, not TRUE/FALSEKonstantin Osipov8 Sep
                        • Re: [STYLE] use true/false in C++, not TRUE/FALSEMats Kindahl8 Sep
                          • Re: [STYLE] use true/false in C++, not TRUE/FALSETor Didriksen8 Sep
                            • Re: [STYLE] use true/false in C++, not TRUE/FALSEMats Kindahl8 Sep
                              • RE: [STYLE] use true/false in C++, not TRUE/FALSEVladislav Vaintroub8 Sep
                                • Re: [STYLE] use true/false in C++, not TRUE/FALSEMats Kindahl8 Sep
                              • Re: [STYLE] use true/false in C++, not TRUE/FALSETor Didriksen8 Sep
                                • Re: [STYLE] use true/false in C++, not TRUE/FALSEMats Kindahl8 Sep
                  • Re: [STYLE] use true/false in C++, not TRUE/FALSEJay Pipes31 Aug
        • Re: [STYLE] use true/false in C++, not TRUE/FALSEMichael Widenius8 Sep
      • Re: [STYLE] use true/false in C++, not TRUE/FALSEMARK CALLAGHAN31 Aug
  • Re: [STYLE] use true/false in C++, not TRUE/FALSEMats Kindahl27 Aug
    • Re: [STYLE] use true/false in C++, not TRUE/FALSEMichael Widenius8 Sep