From owner-freebsd-hackers Wed May 8 12:34:34 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from falcon.prod.itd.earthlink.net (falcon.mail.pas.earthlink.net [207.217.120.74]) by hub.freebsd.org (Postfix) with ESMTP id 6947137B406 for ; Wed, 8 May 2002 12:34:25 -0700 (PDT) Received: from pool0365.cvx21-bradley.dialup.earthlink.net ([209.179.193.110] helo=mindspring.com) by falcon.prod.itd.earthlink.net with esmtp (Exim 3.33 #2) id 175XCc-00030q-00; Wed, 08 May 2002 12:34:19 -0700 Message-ID: <3CD97D9D.E4E734D5@mindspring.com> Date: Wed, 08 May 2002 12:33:49 -0700 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Ian Cc: freebsd-hackers Subject: Re: /usr/include/netinet/in.h References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Ian wrote: > > The general rule is "including includes from includes is bad". > > Okay, it's time to point out that these are opinions, not rules, and > differing opinions exist. Of course they are opinions. They just happen to be, in most cases, codified by the IEEE POSIX and Single Unix Specification standards, however, whose man pages for system interfaces dictate which headers *must* be included for the interfaces. > My opinion is that if a given header file requires some aspect of another > interface, that header should (nay, MUST) include what it needs for itself, > rather than relying on something external to "do the right thing". You mean "something external, like a professional programmer". > Why require thousands of programmers to remember all these interdependancies > as opposed to one programmer encoding the depenancy once where it belongs and > then everyone else can get on with their life and get some real coding done. Because it is their job to know such things, and it is why they "get the big bucks"? So that their code written on Linux will compile without errors on Solaris, FreeBSD, AIX, NetBSD, OpenBSD, HP/UX, etc.? Because "fixing" the broken portability of code by changing the OS is breaking it, not fixing? Because the sooner that a new programmer learns that there are differences between implementations on platforms, and learns to program to standards, rather than to implementations, the better off we will all be? > Within the context of a given project (E.G., FreeBSD) someone's opinion on > this matter may achieve the force of "a rule". Within the larger context of > software engineering in general there is no rule, not even a concensus, on > this issue. My opinion is *far far away* from the force of "a rule" within the FreeBSD project. However, I think that there is a general consensus against promiscuous includes. Including include files automatically because someone *may* use an interface which required both to be in scope is tantamount to mixing Magnesium powder in with the Sulfer powder, so that chemists who need both, and can only remember the Sulfer, get both when they need it. And then if there is Magnesium powder "in scope" when they add the acid, well, they had better just learn to use acid that doesn't react adversely with Magnesium... "Where did I put that Magnesium-proof Sulfuric Acid again?". I may *want* to redefine manifest constants, or provide wrapper versions of functions by renaming the real things and calling the renamed versions from my wrapper versions, so that calls to the code go through my instrumentation. Not permitting me to do redefinition between one "#include" and another "#include" because the second is embedded in the first *robs* me of language features which would allow me to do that. A "#define" doesn't work on an lvalue to another "#define". I guess I could: #define _FOO_H_ 1 #include #undef _FOO_H_ .. insert macro hackery here ... #include To avoid "fee.h" automatically including "foo.h" against my will, but, sheesh, working around the cure is worse than the disease! All to make up for programmers who are incapable of reading the documentation, but somehow supposedly still able to program otherwise correct code, despite their lack of knowledge regarding the interfaces they are using. Anyone who wants to be able to swing a dead cat at a keyboard, and then walk away with a running program, should probably stick to APL... -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message