List:Internals« Previous MessageNext Message »
From:MARK CALLAGHAN Date:August 26 2010 4:17pm
Subject:Re: [STYLE] use true/false in C++, not TRUE/FALSE
View as plain text  
Are there plans to fix my_bool?

It has been quiet on internals so I figured I would ask.

On Thu, Aug 26, 2010 at 6:16 AM, Guilhem Bichot
<guilhem.bichot@stripped> 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.
>
> --
> Mr. Guilhem Bichot <guilhem.bichot@stripped>
> Oracle / MySQL / Optimizer team, Lead Software Engineer
> Bordeaux, France
> www.oracle.com / www.mysql.com
>
> --
> MySQL Internals Mailing List
> For list archives: http://lists.mysql.com/internals
> To unsubscribe:    http://lists.mysql.com/internals?unsub=1
>



--
Mark Callaghan
mdcallag@stripped
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