From: tomas@fabula.de
Cc: guile-devel@gnu.org
Subject: Re: #if vs #ifdef
Date: Thu, 27 Mar 2003 16:26:12 +0100 [thread overview]
Message-ID: <20030327152612.GA13291@www> (raw)
In-Reply-To: <20030327074805.1352f925.dsmith@altustech.com>
On Thu, Mar 27, 2003 at 07:48:05AM -0500, Dale P. Smith wrote:
> On Thu, 27 Mar 2003 00:18:08 -0600
> Rob Browning <rlb@defaultvalue.org> wrote:
>
> > Their argument is that all
> > reasonable compilers will generate the same code either way, and using
> > C code rather than the preprocessor can substantially improve the
> > readability of the code and allow the C compiler to do more thorough
> > analysis of all code paths.
>
> I agree that nested #if's are a horrible thing to wade through, and it
> makes sense to do this. On the other hand, aren't there modes in emacs
> that allow you to hide the #if'ed out code? That would improve
> readability far more than if (..).
>
> I don't understand how it better for the compiler though. I would think
> using #if's effectively edits the code out of the way before the
> compiler has a chance to look at it. Using if (..) gives the compiler
> useless work to do. How is theis better?
This disadvantage is at the same time the advantage (how zen-ish ;-)
The `iffed-out' code gets shaken by the compiler on a regular basis
and some silly bugs get spotted earlier...
(ISTR a funny example for this. Hmmm... Ah, yes, it was in the PostgreSQL
mailing list: the code contained an #elsif instead of an #elif. As long
as the corresponding #if was false, no one noticed, since the preprocessor
dutifully jumped to the matching #endif).
Of course sometimes you can't avoid #if -- when you are sorting out things
which have to be done at compile or link time (e.g. differences in headers,
libraries and such).
Regards
-- tomas
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2003-03-27 15:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-27 6:18 #if vs #ifdef Rob Browning
2003-03-27 9:43 ` tomas
2003-03-27 12:48 ` Dale P. Smith
2003-03-27 15:26 ` tomas [this message]
2003-03-27 15:08 ` Dale P. Smith
2003-03-27 15:56 ` Rob Browning
2003-03-27 15:13 ` Marius Vollmer
2003-03-27 19:47 ` Rob Browning
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/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030327152612.GA13291@www \
--to=tomas@fabula.de \
--cc=guile-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.
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).