From: Junio C Hamano <gitster@pobox.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>
Cc: "Phillip Wood" <phillip.wood@dunelm.org.uk>,
git@vger.kernel.org, "René Scharfe" <l.s.r@web.de>,
"Elijah Newren" <newren@gmail.com>,
"Eric Sunshine" <sunshine@sunshineco.com>
Subject: Re: [PATCH v2 0/3] C99: declare bool experiment a success
Date: Tue, 15 Jul 2025 15:09:09 -0700 [thread overview]
Message-ID: <xmqqikjtf6nu.fsf@gitster.g> (raw)
In-Reply-To: <aHbMlUKNL2CAK_9I@fruit.crustytoothpaste.net> (brian m. carlson's message of "Tue, 15 Jul 2025 21:48:05 +0000")
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
> This series looked good to me. I especially like the fact that we've
> made it easier for me to figure out whether starts_with and friends are
> booleans (that is, true if it starts with the value) or our standard
> zero/negative-one (that is, false if it starts with the value).
Hmph, this is a tangent, I've never thought of it that way.
The "0 is success and negative is failure" is exactly about success
and failure. We expect such a call to succeed most of the time and
failure is a note-worthy event.
Functions like starts_with() and friends, those that Lispers might
name with q suffix, are quite different. A predicate is asking "is
it, or isn't it?" question and returning "false" from it does not
imply a failure in any way.
I wouldn't dream of making them return -1 for "failure", because
starts_with(buf.buf, "#") that finds buf.buf does not begin with "#"
is no way failing.
Anyway, we may start rewriting our old-fashioned idiom to normalize
a "true if non-zero" integers, i.e.
return !!some_true_if_non_zero_integer_variable;
into
return (bool)some_true_if_non_zero_integer_variable;
perhaps ;-).
next prev parent reply other threads:[~2025-07-15 22:09 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 13:26 [PATCH 0/3] C99: declare bool experiment a success Phillip Wood
2025-07-14 13:27 ` [PATCH 1/3] CodingGuildlines: allow the use of bool Phillip Wood
2025-07-14 16:37 ` Junio C Hamano
2025-07-14 13:27 ` [PATCH 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
2025-07-14 16:46 ` Eric Sunshine
2025-07-14 17:20 ` Elijah Newren
2025-07-14 21:14 ` brian m. carlson
2025-07-15 9:36 ` Phillip Wood
2025-07-14 13:27 ` [PATCH 3/3] strbuf: convert " Phillip Wood
2025-07-15 13:52 ` [PATCH v2 0/3] C99: declare bool experiment a success Phillip Wood
2025-07-15 13:52 ` [PATCH v2 1/3] CodingGuildlines: allow the use of bool Phillip Wood
2025-07-16 4:38 ` Jeff King
2025-07-16 4:46 ` Jeff King
2025-07-16 5:06 ` Elijah Newren
2025-07-15 13:52 ` [PATCH v2 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
2025-07-15 13:52 ` [PATCH v2 3/3] strbuf: convert " Phillip Wood
2025-07-15 17:19 ` [PATCH v2 0/3] C99: declare bool experiment a success Elijah Newren
2025-07-15 18:23 ` rsbecker
2025-07-15 19:35 ` Elijah Newren
2025-07-15 20:47 ` rsbecker
2025-07-15 21:06 ` Junio C Hamano
2025-07-15 18:53 ` Junio C Hamano
2025-07-15 21:48 ` brian m. carlson
2025-07-15 22:09 ` Junio C Hamano [this message]
2025-07-16 9:38 ` [PATCH v3 " Phillip Wood
2025-07-16 9:38 ` [PATCH v3 1/3] CodingGuidelines: allow the use of bool Phillip Wood
2025-07-16 9:38 ` [PATCH v3 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
2025-07-16 10:26 ` Karthik Nayak
2025-07-16 9:38 ` [PATCH v3 3/3] strbuf: convert " Phillip Wood
2025-07-16 10:28 ` Karthik Nayak
2025-07-16 10:29 ` [PATCH v3 0/3] C99: declare bool experiment a success Karthik Nayak
2025-07-17 15:21 ` Phillip Wood
2025-07-22 8:09 ` Karthik Nayak
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqikjtf6nu.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=l.s.r@web.de \
--cc=newren@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=sandals@crustytoothpaste.net \
--cc=sunshine@sunshineco.com \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.