This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: style convention: /*foo_p=*/ to annotate bool arguments


> On Oct 4, 2016, at 11:46 AM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> 
> On 4 October 2016 at 16:41,  <Paul.Koning@dell.com> wrote:
>> 
>>> On Oct 3, 2016, at 7:48 PM, Martin Sebor <msebor@gmail.com> wrote:
>>> 
>>> In a recent review Jason and I discussed the style convention
>>> commonly followed in the C++ front end to annotate arguments
>>> in calls to functions taking bool parameters with a comment
>>> along the lines of
>>> 
>>> foo (1, 2, /*bar_p=*/true);
>> 
>> I can't fathom why this makes any sense at all.  Bool is just another data type.  And on top of that, "true" is obviously a value of type bool.  I can't imagine any reason why calls should have funny comments in them that appear only for arguments of that particular type.
> 
> You should get out more :-)
> 
> http://c2.com/cgi/wiki?UseEnumsNotBooleans
> 
> https://ariya.io/2011/08/hall-of-api-shame-boolean-trap
> 
> http://www.flipcode.com/archives/Replacing_Bool_Arguments_With_Enums.shtml


That's good stuff, but it doesn't justify putting funny comments on boolean arguments, it argues for avoiding boolean in the first place.  If you want to propose outlawing the use of boolean type in the coding standard, these articles certainly serve as support for that.  If you want to argue for adding named arguments, as in Python, that works too.

	paul


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]