Re: [PATCH v2 0/3] C99: declare bool experiment a success

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"brian m. carlson" <sandals@xxxxxxxxxxxxxxxxxxxx> 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 ;-).




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux