9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Charles Forsyth <forsyth@terzarima.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] Include guards and multiple includes
Date: Mon, 23 Oct 2006 13:29:05 +0100	[thread overview]
Message-ID: <5e912b5d027f2363dfdaf9b0e45ae3bc@terzarima.net> (raw)
In-Reply-To: <7871fcf50610220937g58fcaa04yfa995a524ab4ae0f@mail.gmail.com>

>>A better argument comes from a recent post on comp.lang.c:

perhaps another approach is constructive, in the sense of considering
what one's trying to achieve with the constructions, and using constructions
to suit, rather than a negative argument (nested #includes are slow to compile,
or there might be unused ones).

for instance, the plan 9 scheme might be said to result from observing that
the unit of shared modularity (in practice) in C code is `the library'.
so: there's one #include file per library.  one library might depend on another,
but not mutually (so #includes can be simply ordered, reflecting that dependency).
you need to know in your own programs which libraries are in use, because it's
C, and your code's global name space is affected by each library (so it makes
sense for you to include the dependent libraries explicitly).
you'll know if you get something out of order, or if it's missing,
because you'll get diagnostics, but only the
first time, and after that you can forget about it.
it's easy to grep. and so on.

the scheme where each thing.c has a thing.h might to be modelled on
programming languages with modules, but each thing.o isn't normally the
unit of re-use.  most projects collect them into libraries, i'd have said.
there might be more to it, though.

for the posix scheme, the rationale must surely be that hardly anyone remembers
all the right names, let alone the right order, and things are scattered enough
or unrelated to particular things (eg, stdlib.h doesn't in practice correspond to any
particular library, and there are many includes for the C library),
so we'll let people slap them in any old way and let the system sort it out.
then there are so many variations from posix, in practice, that people add ./configure


  reply	other threads:[~2006-10-23 12:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-20 18:45 Paul Lalonde
2006-10-20 19:27 ` Joel Salomon
2006-10-20 20:18   ` Russ Cox
2006-10-20 20:37     ` Paul Lalonde
2006-10-22 16:37       ` Joel Salomon
2006-10-23 12:29         ` Charles Forsyth [this message]
2006-10-20 23:15 ` geoff
2006-10-20 23:39   ` Bruce Ellis
2006-10-24 14:32   ` AtomicKobold Design
2006-10-23 12:39 ` Rogelio Serrano
2006-10-23 12:41   ` erik quanstrom
2006-10-23 12:52     ` Rogelio Serrano
2006-10-23 13:26       ` erik quanstrom
2006-10-23 15:30         ` Joel Salomon
2006-10-23 18:43         ` Charles Forsyth
2006-10-23 19:12           ` Joel Salomon
2006-10-23 20:23             ` geoff

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=5e912b5d027f2363dfdaf9b0e45ae3bc@terzarima.net \
    --to=forsyth@terzarima.net \
    --cc=9fans@cse.psu.edu \
    /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 NNTP newsgroup(s).