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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e1f05860a49d6f4e X-Google-Attributes: gid103376,public From: Marin David Condic Subject: Re: Preprocessing Ada Date: 1999/05/26 Message-ID: <374C0C74.B9014654@pwfl.com>#1/1 X-Deja-AN: 482338263 Content-Transfer-Encoding: 7bit Sender: condicma@bogon.pwfl.com References: <374B3689.33FF57B4@aasaa.ofe.org> Content-Type: text/plain; charset=us-ascii Organization: Pratt & Whitney Mime-Version: 1.0 Reply-To: diespammer@pwfl.com Newsgroups: comp.lang.ada Date: 1999-05-26T00:00:00+00:00 List-Id: David Starner wrote: > > I'm writing a library in Ada and I've hit a couple things where I would > use #ifdef's in C. I would like to offer alternate algorithims for the > same function that can be chosen at compile time. I would also like to > add an expensive verification call to the front of each function that > can be turned on and off at compile time (expensive enough that I want > it to be seperate from Pragma Assert.) > > 1. Is there a more 'Ada'-like way to do this? > This is an area where angels fear to tread! :-) One thing I have found works with some compilers is to create a Boolean constant somewhere and put "if" statements into the code testing this constant. If the compiler is good, it will know which path cannot be reached and will not generate code for that path. Changing the constant and recompiling will let you select the alternate path. Of course, this doesn't give you the ability to do any conditional compilation in the declarative region. But this is not "The Ada Way" anyway. What your problem sounds like is one where you have divergent paths in your configuration. If you don't have a Configuration Management tool to help you with divergent paths, you might consider one. You can construct something rudimentary with subdirectories and search paths. Doing this would enable you to have a common interface specification for a package and then having two or more implementations conforming to the specification which are maintained on divergent paths. Putting things in the code for conditional compilation seems to me to be a poor substitute for good CM. Another thing you might want to consider WRT your expensive verification call would be importing a subprogram as a generic parameter. That, or obtaining an access object to a subprogram. In either case, it sounds complex and you might want to rethink the necessity of doing any of it. An alternative here is also the divergent path notion of CM where down one path you get a body with full-up implementation of the verification and down the other path, you get a subprogram stub which, hopefully, gets optimized away. Hope this helps. MDC -- Marin David Condic Real Time & Embedded Systems, Propulsion Systems Analysis United Technologies, Pratt & Whitney, Large Military Engines M/S 731-95, P.O.B. 109600, West Palm Beach, FL, 33410-9600 ***To reply, remove "bogon" from the domain name.*** Visit my web page at: http://www.flipag.net/mcondic