unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: Daniel Kahn Gillmor <dkg@fifthhorseman.net>, notmuch@notmuchmail.org
Subject: Re: [PATCH 3/8] CLI: replace some constructs with more uncrustify friendly ones
Date: Mon, 17 Jun 2019 01:01:39 -0400	[thread overview]
Message-ID: <87zhmgiz4c.fsf@tethera.net> (raw)
In-Reply-To: <87blyx1mp0.fsf@fifthhorseman.net>

Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:

> On Thu 2019-06-13 08:08:32 -0300, David Bremner wrote:
>>    - add parens in some ternery operators
>
> itym "ternary"

yep.

>
>> @@ -120,13 +120,13 @@ _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *
>>  static int _opt_set_count (const notmuch_opt_desc_t *opt_desc)
>>  {
>>      return
>> -	!!opt_desc->opt_inherit +
>> -	!!opt_desc->opt_bool +
>> -	!!opt_desc->opt_int +
>> -	!!opt_desc->opt_keyword +
>> -	!!opt_desc->opt_flags +
>> -	!!opt_desc->opt_string +
>> -	!!opt_desc->opt_position;
>> +	(bool) opt_desc->opt_inherit +
>> +	(bool) opt_desc->opt_bool +
>> +	(bool) opt_desc->opt_int +
>> +	(bool) opt_desc->opt_keyword +
>> +	(bool) opt_desc->opt_flags +
>> +	(bool) opt_desc->opt_string +
>> +	(bool) opt_desc->opt_position;
>>  }
>
> i find this is deeply weird.  It looks like it is coercing various types
> into bools, and then summing a list of bools.
>
> While the spec might well say that the sum of two bools should be an int
> (i haven't checked), it's not at all obvious to me that the infix +
> operator should assume that type.  (float + float is a float, not an
> int, for example)

Yes, the C11 standard seems pretty clear here, 6.3.1.{1,2}

>
> in some sense, the !! operator works better here because i know that its
> output is likely to be an int, so summing makes sense.
>

For whatever reason I never used this idiom much. I _think_ it should be
replaced in new code with (bool), but I don't feel strongly about it.
There's an argument to be made that we should really just use ternary
operators there. I would accept a patch to do that if you feel strongly
enough.

d

  reply	other threads:[~2019-06-17  5:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13 11:08 v2 uncrustify David Bremner
2019-06-13 11:08 ` [PATCH 1/8] STYLE: document rules for calls, block comments, ternary ops David Bremner
2019-06-13 11:12   ` David Bremner
2019-06-13 11:08 ` [PATCH 2/8] uncrustify: indent classes David Bremner
2019-06-13 11:08 ` [PATCH 3/8] CLI: replace some constructs with more uncrustify friendly ones David Bremner
2019-06-16 17:09   ` Daniel Kahn Gillmor
2019-06-17  5:01     ` David Bremner [this message]
2019-06-17 15:40       ` Daniel Kahn Gillmor
2019-06-13 11:08 ` [PATCH 4/8] cli: run uncrustify David Bremner
2019-06-13 19:52   ` Tomi Ollila
2019-06-14 10:30     ` David Bremner
2019-06-14 10:50       ` David Bremner
2019-06-13 11:08 ` [PATCH 5/8] util: " David Bremner
2019-06-13 11:08 ` [PATCH 6/8] compat: " David Bremner
2019-06-13 11:08 ` [PATCH 7/8] parse-time-string: " David Bremner
2019-06-13 11:08 ` [PATCH 8/8] lib: " David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zhmgiz4c.fsf@tethera.net \
    --to=david@tethera.net \
    --cc=dkg@fifthhorseman.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).