comp.lang.ada
 help / color / mirror / Atom feed
From: Samuel Mize <smize@imagin.net>
Subject: Re: PRECOMPILATION
Date: 1999/02/18
Date: 1999-02-18T00:00:00+00:00	[thread overview]
Message-ID: <7ahor8$otv@news1.newsguy.com> (raw)
In-Reply-To: 36C0B5D4.DEF83A66@averstar.com

Tucker Taft <stt@averstar.com> wrote:
> =:-) Vincent wrote:
>> 
>> Are there precompilation instructions in Ada95,
>> like in C (#ifdef,...etc) ? In other words, how can
>> I set compilation conditions ?
...
> However, we have had good experience with making the
> unit of variation be the whole source file.

Of course, this may affect your design. You'll have to provide
some higher-level package that interacts with the system, instead
of just embedding code to do low-level system things throughout
your program.

This is disquieting to someone with a C-style design mindset, but
is expected by an Ada-style mindset.  I'm not denigrating EITHER
mindset.  I do point out that C people write large, involved,
nested #ifdef structures instead without a second thought because
that's "normal" to them.  The Ada approach seems like "a lot of
bother" -- they see the "extra" work in Ada, but don't observe
how much it reduces the coding burden in other areas.

If you prefer, you can maintain the platform-specific packages in
a "pre-Ada" form, with conditional compilation commands, and use
a preprocessor to generate your platform-specific versions.  IIRC,
Rational has a fairly nice implementation of this.

A couple of points that may help people with C-style preprocessor
experience:

C-experienced people probably expect platform-specific issues to be
shot through the whole program, like cancer.  For instance, if a
system call's parameter can be 64-bit or 32-bit depending on the
platform, you may have #ifdefs around every call to it, and every
declaration of a variable to use as a parameter for it.

So they fear the spectre of having to maintain parallel files for
a huge number of units, and getting their logic out of synch.

This is greatly reduced by using Ada's strong typing and separate
compilation capabilities.  Once you've set up a fairly small
platform interface, all the rest of the source code is invariant.
But it takes a bit of experience to really believe that.

Also, a C-experienced developer feels he can look at just one
file and make sure that each element has an alternative defined
for each platform.

It seems so simple in theory...

Of course, if there are dependencies between elements, you wind up
with nested #ifdefs, and elements which exist in some configurations
but not in others.  You wind up with nightmares where, for instance,
a function should have been declared to return long_int on platform
X, but X didn't get into the #ifdef, so the compiler assumes it
returns an integer, and everything links and runs.  Badly.

Again, Ada largely takes care of this concern.  If you missed an
element that you need in one of your platform-specific files, the
program won't compile.  It's actually easier to maintain most
cross-platform dependencies in Ada, once you adapt your design to
the Ada mindset.

Best,
Sam Mize

-- 
Samuel Mize -- smize@imagin.net (home email) -- Team Ada
Fight Spam: see http://www.cauce.org/ \\\ Smert Spamonam




  parent reply	other threads:[~1999-02-18  0:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-09  0:00 PRECOMPILATION =:-) Vincent
1999-02-09  0:00 ` PRECOMPILATION Larry Kilgallen
1999-02-09  0:00   ` PRECOMPILATION Pascal MALAISE
1999-02-09  0:00     ` PRECOMPILATION Tucker Taft
1999-02-09  0:00     ` PRECOMPILATION Tom Moran
1999-02-10  0:00       ` PRECOMPILATION Corey Ashford
1999-02-10  0:00       ` PRECOMPILATION robert_dewar
1999-02-10  0:00       ` PRECOMPILATION dennison
1999-02-09  0:00     ` PRECOMPILATION Tom Moran
1999-02-10  0:00       ` PRECOMPILATION Pascal MALAISE
1999-02-10  0:00         ` PRECOMPILATION Tom Moran
1999-02-11  0:00           ` PRECOMPILATION Pascal MALAISE
1999-02-12  0:00             ` PRECOMPILATION robert_dewar
1999-02-14  0:00               ` PRECOMPILATION Pascal MALAISE
1999-02-09  0:00 ` PRECOMPILATION Tucker Taft
1999-02-10  0:00   ` PRECOMPILATION Fraser Wilson
1999-02-18  0:00   ` Samuel Mize [this message]
1999-02-18  0:00     ` PRECOMPILATION Rakesh Malhotra
1999-02-19  0:00       ` PRECOMPILATION Samuel Mize
1999-02-18  0:00     ` PRECOMPILATION robert_dewar
1999-02-28  0:00     ` PRECOMPILATION Robert A Duff
1999-02-09  0:00 ` PRECOMPILATION Tom Moran
1999-02-10  0:00   ` PRECOMPILATION Pascal MALAISE
1999-02-10  0:00     ` PRECOMPILATION Tom Moran
1999-02-09  0:00 ` PRECOMPILATION Marin David Condic
replies disabled

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