Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!think.com!spool.mu.edu!sol.ctr.columbia.edu!caen!uflorida!gatech!mcnc!decwrl!infopiz!lupine!rfg From: rfg@NCD.COM (Ron Guilmette) Newsgroups: comp.lang.c++ Subject: Re: Problems maintaining header files Message-ID: <3707@lupine.NCD.COM> Date: 4 Feb 91 22:24:59 GMT References: <15917@reed.UUCP> <6107@stpstn.UUCP> Organization: Network Computing Devices, Inc., Mt. View, CA Lines: 45 In article <6107@stpstn.UUCP> lerman@stpstn.UUCP (Ken Lerman) writes: > >Objective-C (please hold the flames down to a dull roar) uses '#import >' to mean the same thing as '#include ' except do >nothing if the file has already been imported. This is MUCH nicer >than '#pragma once' and might be a useful addition to C++. Contrary to Ken's misguided opinions, #import is *not* much nicer than #pragma once. Quite the contrary, it is much stupider. Consider this. I have an include file which should only be included at most one time during an entire compilation. If it gets included more than once then I'll get errors. Now ask yourself this one question. Is the fact that this file must only be included once into an entire compilation a property of the include file in question, or is it a property of all of the files which include the include file in question? Quite obviously, the "must only be included once" property is a property of the "includee". It is *not* a property of all of the "includers". This special property should therefore be expressed by having something special coded into the (one and only) "includee". That way, if the includee changes with respect to this one property, you can just change the text of the includee and leave the text of all of the includers alone. It's painfully obvious that Stepstone got it bass-ackwards in Objective-C (with their #import directive). I guess that their existing customer base is either too large or too stagnant to permit them to to recognize their mistake and to convert over to using #pragma once. Either that or else they have a bad case of `Not Invented Here' syndrome. Also note that `#pragma once' is likely to be portable to all existing ANSI C environments because ANSI C requires that ANSI C preprocessors *must* ignore all #pragmas that they do not understand. Most ANSI C compiler will totally barf on #import however, and the ANSI C standard gives them full permission to do so. -- // Ron Guilmette - C++ Entomologist // Internet: rfg@ncd.com uucp: ...uunet!lupine!rfg // Motto: If it sticks, force it. If it breaks, it needed replacing anyway.