From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f34f1a1939dc0c40 X-Google-Attributes: gid103376,public From: Simon Brady Subject: Re: conditional compilation Date: 2000/08/01 Message-ID: <3985FB16.82D140BB@below.for.email.address>#1/1 X-Deja-AN: 652977420 Cache-Post-Path: the-rowan.albatross.co.nz!sbrady@kakapo.otago.ac.nz Content-Transfer-Encoding: 7bit References: <87d7jvp3qq.fsf@chiark.greenend.org.uk> <39857E5F.33C40014@acm.com> X-Original-NNTP-Posting-Host: ns.albatross.co.nz X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Abuse-Info: Otherwise we will be unable to process your complaint properly X-Complaints-To: abuse@GigaNews.Com X-Trace: sv2-NABUhETvqBWTf50/ATLK/PKy0p29HiUNdFeCFwBDuICc6l/QGgEzj9v4MlW9g8pjR7/+msSVGN6NpjT!y61bZuBcjGhUP1wX6U8ReIgP Organization: University of Otago CS Dept X-Original-Trace: 1 Aug 2000 10:17:59 +1200, ns.albatross.co.nz X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/) MIME-Version: 1.0 NNTP-Posting-Date: Mon, 31 Jul 2000 17:18:11 CDT Newsgroups: comp.lang.ada Date: 2000-08-01T00:00:00+00:00 List-Id: "Marin D. Condic" wrote: > > I know from experience with a few different embedded compilers that it > was a common optimization to remove dead code. A construct such as: > > declare > Debug : constant Boolean := False ; > begin > if (Debug) then > Do_Some_Stuff ; > else > Do_Some_Other_Stuff ; > end if ; > end ; > > would result in the call to Do_Some_Stuff being removed from the object > code. It was a reasonably effective method of getting conditional > compilation. Maybe I'm being pedantic here, but I don't consider this an acceptable substitute for "real" conditional compilation. Sure, with a good compiler it achieves the results (debug support with zero runtime cost in the production build), but from a maintenance perspective it strikes me as a Bad Thing. Why? Because it overloads the meaning of the if-then control structure. Compile-time configuration control and runtime flow control are quite separate issues, and IMO they need to be clearly distinguished for both human and automated readers of the code. For example, some Unix tools take a "print debug info" command-line switch, so the above code might be just as sensible if Debug was a variable and not a constant. In a large, unfamiliar source tree, how would you know? >From my own (small-scale) experience I like what conditional compilation can achieve, especially the way it allows debug builds loaded up with paranoic self-test code.I would certainly like to see a standardised, portable method of achieving such ends in Ada - however, the question of (a) whether conditional compilation is the way to do it and (b) whether support belongs in or out of the language seems to be very much open. I'd be curious to hear what people with larger-scale experience think of this. Simon Brady sjbrady Research Assistant, Computer Science Dept. at University of Otago, Dunedin, New Zealand acm dot org