unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Booleans
Date: Sun, 15 Dec 2013 15:03:50 -0800	[thread overview]
Message-ID: <52AE3556.6080704@cs.ucla.edu> (raw)
In-Reply-To: <83vbyqdncv.fsf@gnu.org>

Eli Zaretskii wrote:

> I'm not sure I understand why we want such a wholesale
> replacement of 0/1 with false/true.

It's no big deal and we could easily change it back if
desired.  I did it primarily because Stefan suggested that I
do so, while changing int to bool etc.

> why is it a good idea to convert everything, including bitfields (which
> required introduction of a new non-standard typedef), into booleans?

If a value is a boolean, it typically makes things easer on
the reader, the debugger, etc. to know that it's a boolean
and not an integer, so that one needn't worry about values
other than 0 and 1.

bool_bf is a response to trunk bzr 115272, which used 'bool
inhibit_shrinking : 1;'.  This is not portable to pre-C99
platforms.  I temporarily fixed that by changing 'bool' by
'unsigned' in trunk bzr 115280, but for maintainability
'bool' is indeed better, and 'bool_bf' attempts to support
this while still maintaining portability to pre-C99
platforms.

If we could assume C99 or later, we could get rid of bool_bf
and just use bool.  I'm thinking of proposing such an
assumption for after the next release.  This would allow us
to use some other C99 features, such as declarations after
statements, which would make Emacs easier to maintain.

> should have been a separate commit, as
> it is not a mechanical replacement, far from it.

It was a judgment call.  Perhaps I should have separated it
out, though it's no big deal.  It was a case of an int value
being used as a boolean with values 0 and -1.

>   -#if 0
>   +#if false
> 
> ... I'm afraid I don't see the point

I tried to be reasonably systematic in replacing uses of 0
and 1 as booleans in the set of files that I was looking at;
this included the use of booleans in preprocessor
expressions.  It would be an odd style to use '0' for false
preprocessor expressions, while using 'false' for false
expressions everywhere else.



  reply	other threads:[~2013-12-15 23:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-15 17:40 Booleans Eli Zaretskii
2013-12-15 23:03 ` Paul Eggert [this message]
2013-12-16  3:43   ` Booleans Stefan Monnier
2013-12-16  3:44   ` Booleans Eli Zaretskii
2013-12-16  7:39   ` Booleans Jarek Czekalski
2013-12-16 17:28     ` Booleans Paul Eggert

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://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=52AE3556.6080704@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.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://git.savannah.gnu.org/cgit/emacs.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).