comp.lang.ada
 help / color / mirror / Atom feed
From: Marin David Condic <condicma@bogon.pwfl.com>
Subject: Re: Preprocessing Ada
Date: 1999/05/26
Date: 1999-05-26T00:00:00+00:00	[thread overview]
Message-ID: <374C0C74.B9014654@pwfl.com> (raw)
In-Reply-To: 374B3689.33FF57B4@aasaa.ofe.org

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




      parent reply	other threads:[~1999-05-26  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-25  0:00 Preprocessing Ada David Starner
1999-05-25  0:00 ` David Botton
1999-05-26  0:00 ` fraser
1999-05-26  0:00 ` Dale Stanbrough
1999-05-26  0:00 ` Marin David Condic [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox