comp.lang.ada
 help / color / mirror / Atom feed
* Conditional Code in Ada 95?
@ 1998-08-21  0:00 Rex Reges
  1998-08-21  0:00 ` Gene Ouye
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Rex Reges @ 1998-08-21  0:00 UTC (permalink / raw)


I just saw some Ada95 code riddled with conditional
compilation statements. I wasn't aware that this
was part of Ada95 and I can't find it in the ARM.
Is this some feature that compiler vendors have
all decided to support?

Rex Reges




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-21  0:00 Conditional Code in Ada 95? Rex Reges
@ 1998-08-21  0:00 ` Gene Ouye
  1998-08-24  0:00   ` Mark A Biggar
  1998-08-22  0:00 ` Gautier.DeMontmollin
  1998-08-22  0:00 ` dewarr
  2 siblings, 1 reply; 18+ messages in thread
From: Gene Ouye @ 1998-08-21  0:00 UTC (permalink / raw)


Rex Reges wrote:
> I just saw some Ada95 code riddled with conditional
> compilation statements. I wasn't aware that this
> was part of Ada95 and I can't find it in the ARM.
> Is this some feature that compiler vendors have
> all decided to support?

Rational Apex includes a preprocessor that can be used for conditional
compilation, but this is certainly NOT something that the ARM requires,
and Ada compiler vendors are NOT required to provide it.  As far as I
know, the compiler vendors have not decided to support any particular
conditional compilation syntax much less conditional compilation in
general.

Gene Ouye <.g.e.n.e.o.@.r.a.t.i.o.n.a.l...c.o.m.>




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-21  0:00 Conditional Code in Ada 95? Rex Reges
  1998-08-21  0:00 ` Gene Ouye
@ 1998-08-22  0:00 ` Gautier.DeMontmollin
  1998-08-23  0:00   ` dewar
  1998-08-24  0:00   ` Michael F Brenner
  1998-08-22  0:00 ` dewarr
  2 siblings, 2 replies; 18+ messages in thread
From: Gautier.DeMontmollin @ 1998-08-22  0:00 UTC (permalink / raw)


Rex Reges <rex.r.reges@boeing.com> writes:

> I just saw some Ada95 code riddled with conditional
> compilation statements. I wasn't aware that this
> was part of Ada95 and I can't find it in the ARM.

Fortunately... The clean (and compatible) way remains
hardware-specific units when needed and, within an unit,
constants keys like that:

with text_io; use text_io;

procedure condcomp is
 debug:   boolean:= false;
 verbose: boolean:= true;
 begin
  if debug then put_line("this is for debug"); end if;
  if verbose then put_line("verbosity"); end if;
 end;

Question: which compiler/optimizer will skip the unused
'put_line("this is for debug");' ?...

Gautier





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-21  0:00 Conditional Code in Ada 95? Rex Reges
  1998-08-21  0:00 ` Gene Ouye
  1998-08-22  0:00 ` Gautier.DeMontmollin
@ 1998-08-22  0:00 ` dewarr
  2 siblings, 0 replies; 18+ messages in thread
From: dewarr @ 1998-08-22  0:00 UTC (permalink / raw)


In article <35DDFB42.1311@boeing.com>,
  rex.r.reges@boeing.com wrote:
> I just saw some Ada95 code riddled with conditional
> compilation statements. I wasn't aware that this
> was part of Ada95 and I can't find it in the ARM.
> Is this some feature that compiler vendors have
> all decided to support?
>
> Rex Reges
>
There is no such feature in standard Ada 95 (this was very
deliberately omitted from the language design for reasons that
have been extensively discussed here and elsewhere in the past).

Many vendors have indeed implemented some kind of separate
conditional compilation semantics, e.g. GNAT comes with the
gnatprep tool that provides preprocessing capability.

There is no agreed on standard for these preprocessing
capabilities, so their use should be avoided in portable code.

Robert Dewar
Ada Core Technologies


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-22  0:00 ` Gautier.DeMontmollin
@ 1998-08-23  0:00   ` dewar
  1998-08-24  0:00     ` Gautier.DeMontmollin
  1998-08-24  0:00   ` Michael F Brenner
  1 sibling, 1 reply; 18+ messages in thread
From: dewar @ 1998-08-23  0:00 UTC (permalink / raw)


In article <2$$CdIjQwTPX@nedcu4>,
  Gautier.DeMontmollin@maths.unine.ch wrote:
> Rex Reges <rex.r.reges@boeing.com> writes:
>
> > I just saw some Ada95 code riddled with conditional
> > compilation statements. I wasn't aware that this
> > was part of Ada95 and I can't find it in the ARM.
>
> Fortunately... The clean (and compatible) way remains
> hardware-specific units when needed and, within an unit,
> constants keys like that:
>
> with text_io; use text_io;
>
> procedure condcomp is
>  debug:   boolean:= false;
>  verbose: boolean:= true;
>  begin
>   if debug then put_line("this is for debug"); end if;
>   if verbose then put_line("verbosity"); end if;
>  end;
>
> Question: which compiler/optimizer will skip the unused
> 'put_line("this is for debug");' ?...
>
> Gautier
>

I would think that virtually any Ada compiler would delete
the dead code if the booleans are constant, but asking for
the deletion in the variable case is a bit more strenuous.
Note that there is absolutely NO reason that these are
variables rather than constants in your example. Remember
an important rule in Ada is that you ALWAYS use the constant
keyword whereever you can.

GNAT will most certainly delete the code in question whether
or not a constant keyword is present.

Robert Dewar
Ada Core Technologies

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-23  0:00   ` dewar
@ 1998-08-24  0:00     ` Gautier.DeMontmollin
  0 siblings, 0 replies; 18+ messages in thread
From: Gautier.DeMontmollin @ 1998-08-24  0:00 UTC (permalink / raw)


(...)
>>  debug:   boolean:= false;
>>  verbose: boolean:= true;
>>  begin
>>   if debug then put_line("this is for debug"); end if;
>>   if verbose then put_line("verbosity"); end if;
>>  end;

> I would think that virtually any Ada compiler would delete
> the dead code if the booleans are constant, but asking for
> the deletion in the variable case is a bit more strenuous.
> Note that there is absolutely NO reason that these are
> variables rather than constants in your example. Remember
> an important rule in Ada is that you ALWAYS use the constant
> keyword whereever you can.

I had forgotten the "constant" keyword in my example - sigh...
Of course a variable is a bit inappropriated for conditional
compiling...

> GNAT will most certainly delete the code in question whether
> or not a constant keyword is present.

Tested: 

Without optimization, the variable is tested
and in the constant case a JMP is performed over the unused code.

With -O1 or better, the unusued code is deleted in any case
(in the variable case, it means that the optimizer sees that the
 "debug" variable was not modified from its initial value "false"
 at that moment!). It's interesting to note that "this is for debug"
string is kept in data, even though the code that could reference
it has disappeared... Of course this optimisation is made at a later
step of code generation, I guess.

-- 
Gautier





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-22  0:00 ` Gautier.DeMontmollin
  1998-08-23  0:00   ` dewar
@ 1998-08-24  0:00   ` Michael F Brenner
  1998-08-25  0:00     ` dewarr
  1998-08-25  0:00     ` Jean-Pierre Rosen
  1 sibling, 2 replies; 18+ messages in thread
From: Michael F Brenner @ 1998-08-24  0:00 UTC (permalink / raw)


>> I just saw some Ada95 code riddled with conditional
>> compilation statements. I wasn't aware that this
>> was part of Ada95 and I can't find it in the ARM.

> Fortunately... The clean (and compatible) way remains
> hardware-specific units when needed and, within an unit,
> constants like ...

Yes, constants are good for executable statements. However, there is
no way WITHIN the Ada language to select which of the hardware
specific bodies to use with a multi-platform package.

This is to be considered a requirement for Ada 200X.





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-21  0:00 ` Gene Ouye
@ 1998-08-24  0:00   ` Mark A Biggar
  1998-08-27  0:00     ` Samuel T. Harris
  0 siblings, 1 reply; 18+ messages in thread
From: Mark A Biggar @ 1998-08-24  0:00 UTC (permalink / raw)


Gene Ouye wrote:
> Rex Reges wrote:
> > I just saw some Ada95 code riddled with conditional
> > compilation statements. I wasn't aware that this
> > was part of Ada95 and I can't find it in the ARM.
> > Is this some feature that compiler vendors have
> > all decided to support?
> Rational Apex includes a preprocessor that can be used for conditional
> compilation, but this is certainly NOT something that the ARM requires,
> and Ada compiler vendors are NOT required to provide it.  As far as I
> know, the compiler vendors have not decided to support any particular
> conditional compilation syntax much less conditional compilation in
> general.

It should also be noted that most ANSI standard C compiler preprocessors
will not work with Ada code.  The 2 languages have just enough differences
in the way they break text up into tokens that a ANSI C preprocessor (whose
operation is defined in terms of token strings not characters) gets
very confused, especially about ' attributes.  Older pre-ANSI text based
C preporcessors may work depending on how they habdle quoting.

--
Mark Biggar
mark.a.biggar@lmco.com




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-24  0:00   ` Michael F Brenner
@ 1998-08-25  0:00     ` dewarr
  1998-08-25  0:00       ` Richard D Riehle
  1998-08-26  0:00       ` Michael F Brenner
  1998-08-25  0:00     ` Jean-Pierre Rosen
  1 sibling, 2 replies; 18+ messages in thread
From: dewarr @ 1998-08-25  0:00 UTC (permalink / raw)


In article <6rrtuf$cqg@top.mitre.org>,
  mfb@mbunix.mitre.org (Michael F Brenner) wrote:
> >> I just saw some Ada95 code riddled with conditional
> >> compilation statements. I wasn't aware that this
> >> was part of Ada95 and I can't find it in the ARM.
>
> > Fortunately... The clean (and compatible) way remains
> > hardware-specific units when needed and, within an unit,
> > constants like ...
>
> Yes, constants are good for executable statements. However, there is
> no way WITHIN the Ada language to select which of the hardware
> specific bodies to use with a multi-platform package.
>
> This is to be considered a requirement for Ada 200X.
>
I can't see what has changed that should suggest reconsidering
this decision. Steelman specified no conditional compilation in
Ada, Ada 83 carefully considered that specification and agreed
with it, and Ada 95 also agreed. I see no reason to revisit this
unless there is new information, there has always been general
agreement that conditional compilation does not belong in the
language proper. Michael, what new information is available
that would suggest revisiting it (the fact that Michael Brenner
wants it does not count as new information :-)

>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-24  0:00   ` Michael F Brenner
  1998-08-25  0:00     ` dewarr
@ 1998-08-25  0:00     ` Jean-Pierre Rosen
  1998-08-28  0:00       ` Laurent Pautet
  1 sibling, 1 reply; 18+ messages in thread
From: Jean-Pierre Rosen @ 1998-08-25  0:00 UTC (permalink / raw)



Michael F Brenner a �crit dans le message <6rrtuf$cqg@top.mitre.org>...
>>> I just saw some Ada95 code riddled with conditional
>>> compilation statements. I wasn't aware that this
>>> was part of Ada95 and I can't find it in the ARM.
>
>> Fortunately... The clean (and compatible) way remains
>> hardware-specific units when needed and, within an unit,
>> constants like ...
>
>Yes, constants are good for executable statements. However, there is
>no way WITHIN the Ada language to select which of the hardware
>specific bodies to use with a multi-platform package.


However, there is something that's damn close to it:

with Hardware_Specific_1;
package Hardware_Specific renames Hardware_Specific_1;

and then use package Hardware_Specific all over the place. If you change
hardware, there is one line to change in the whole program.







^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-25  0:00     ` dewarr
@ 1998-08-25  0:00       ` Richard D Riehle
  1998-08-26  0:00         ` dennison
  1998-08-26  0:00       ` Michael F Brenner
  1 sibling, 1 reply; 18+ messages in thread
From: Richard D Riehle @ 1998-08-25  0:00 UTC (permalink / raw)


In article <6rtike$b3$1@nnrp1.dejanews.com>,
	dewarr@my-dejanews.com wrote:

>I can't see what has changed that should suggest reconsidering
>this decision. Steelman specified no conditional compilation in
>Ada, Ada 83 carefully considered that specification and agreed
>with it, and Ada 95 also agreed. I see no reason to revisit this
>unless there is new information, there has always been general
>agreement that conditional compilation does not belong in the
>language proper. Michael, what new information is available
>that would suggest revisiting it (the fact that Michael Brenner
>wants it does not count as new information :-)
>
There is probably nothing new information on this, Robert.  It does,
however, turn out to be a useful capability.  I have direct experience
with Ada development shops that have written their own conditional
compilation software.  One example is that of an Ada developer that
took advantage of the portability of vanilla-flavored Ada to do much
of its embedded software programming on a bunch of low-cost PC-based
computers.  They purchased one copy of the high-priced embedded
cross-compiler and used it only when necessary to target the actual
target processor.  Most of the other compilations were done using the
low-cost compilers.

The conditional compilation software eliminated comment lines for the
el-cheapo compiler so it could emulate the features of the target
computer.  When it came time to compile to the target, the conditional
compilation elminated comment lines for that compiler.   Of course,
hardware dependent code was, as much as possible, pushed to the 
lowest possible level of the design.  This turned out
to provide some cost savings for a large development team creating
Ada software for a non-military application.  As far as I know, they
are still using this technique.  It works for them and they are
very successful with Ada.

The downside of this usage of conditional compilation is that the
prices of embedded compilers stay high because fewer are sold.   

There are many other examples of conditional compilation in Ada that 
make sense.  I do agree with you Robert that it should not be a part
of the core language.  As an idea for some future Annex?  Maybe.

Richard
richard@adaworks.com
http://www.adaworks.com





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-25  0:00       ` Richard D Riehle
@ 1998-08-26  0:00         ` dennison
  1998-08-26  0:00           ` Richard D Riehle
  0 siblings, 1 reply; 18+ messages in thread
From: dennison @ 1998-08-26  0:00 UTC (permalink / raw)


In article <6rvdbs$c40@sjx-ixn3.ix.netcom.com>,
  Richard D Riehle <laoXhai@ix.netcom.com> wrote:

> The conditional compilation software eliminated comment lines for the
> el-cheapo compiler so it could emulate the features of the target
> computer.  When it came time to compile to the target, the conditional
> compilation elminated comment lines for that compiler.   Of course,

Can't you get the same effect by using a build tool like gnumake? Gnumake is
about as standard as they come. I'm pretty sure gnu has a pre-processor that
should be available on every platorm gnumake is as well.

Personally, I would greatly support the decision not to add a pre-compiler.
Anyone who has ever tried to track down a problem in the source code of
gnu-emacs knows what a nightmare such code can turn into. It is anathema to
the primary Ada goal of easy to understand code.


--
T.E.D.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-25  0:00     ` dewarr
  1998-08-25  0:00       ` Richard D Riehle
@ 1998-08-26  0:00       ` Michael F Brenner
  1 sibling, 0 replies; 18+ messages in thread
From: Michael F Brenner @ 1998-08-26  0:00 UTC (permalink / raw)



Mike > Yes, constants are good for executable statements. However, there is
     > no way WITHIN the Ada language to select which of the hardware
     > specific bodies to use with a multi-platform package.
     > This is to be considered a requirement for Ada 200X.

Responder > I can't see what has changed that should suggest reconsidering
          > this decision. Steelman specified no conditional compilation in
          > Ada, Ada 83 carefully considered that specification and agreed
          > with it, and Ada 95 also agreed. I see no reason to revisit this
          > unless there is new information, there has always been general
          > agreement that conditional compilation does not belong in the
          > language proper. 

You are right, as far as a C-preprocessor making the code harder to read.
However, the requirement would not be for a preprocessor, but for a
means WITHIN the language of selecting from among multiple package
bodies which share the same face (package specification modulo
the WITH list and the private part).

Jean Pierre > with Hardware_Specific_1;
            > package Hardware_Specific renames Hardware_Specific_1;

This work beautifully in many cases in Ada-95. For those projects
that are stuck in Ada-83 a little while longer until the remaining
bugs in various Ada-95 compilers or annexes are being worked out,
this is not possible, because Ada-83 forbids it. Because of problems
with supporting DOS, packed arrays, and other reasons, etc., the 
majority of code in the Ada language still must adhere to Ada-83.
 
Responder > Michael, what new information is available
          > that would suggest revisiting it (the fact that 
          > Michael Brenner wants it does not count as new information :-)

I am curious why you think that the requirements process should
not count requirements originating from me, a large user and
maintainer of Ada software? It should be a requirement of Ada 200X
that all of us can give inputs to the requirements process and
participate in the decision making process as well. I will start
by graning you amity -- I will consider any requirements that
originate with you, and will accept them unless I have a good reason
not to. I will count all of your requirements and suggestions as
a valuable contribution to the community.

However, it is approrpriate to repeat here the admonition that the
primary changes in  Ada 200X should be efficiency improvements and
language definition-bug-fixes, as opposed to major changes. The
only substantial addition to Ada 200X should be a full set of 
interfaces to the open (non-proprietary) standards like Java/SQL/
ODBC/JDBC/DOS/Posix/ and to common I/O devices like mouses, SCSI disks,
CDs, MIDI instruments, superVGA pixels, serial ports, interrupts, and
multiple keypress immediate keyboards.

Some of the changes in Ada 200X are:
  - get rid of any UNNECESSARY checking in various chapters
  - permit passing nongeneric packages to generic packages
  - keep things static that were static before passing them to generics
  - a way to select which body to compile for platform independent packages,
  - use a stream_io.stream intead of a text_io.stream for text_io
  

Mike





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-26  0:00         ` dennison
@ 1998-08-26  0:00           ` Richard D Riehle
  1998-08-27  0:00             ` dennison
  0 siblings, 1 reply; 18+ messages in thread
From: Richard D Riehle @ 1998-08-26  0:00 UTC (permalink / raw)


In article <6s13q3$5v9$1@nnrp1.dejanews.com>,
	dennison@telepath.com wrote:

In response to R.Riehle's earlier anecdote about conditional compilation

>Can't you get the same effect by using a build tool like gnumake? Gnumake
is
>about as standard as they come. I'm pretty sure gnu has a pre-processor
that
>should be available on every platorm gnumake is as well.
>
>Personally, I would greatly support the decision not to add a pre-compiler.
>Anyone who has ever tried to track down a problem in the source code of
>gnu-emacs knows what a nightmare such code can turn into. It is anathema to
>the primary Ada goal of easy to understand code.

 This presumes the availability, 1) of gnu, 2) Ada 95.  The organization
 mentioned in my post continues to use only Ada 83, as do many shops who
 continue to use Ada.  Also, gnumake is not universally available even
 if an organization decides to use Ada 95.  In the case of the 
 development group I referenced, they are non-military, use Ada by
 choice, and have little incentive to move to Ada 95 since Ada 83 has
 been successful in their products for a long time.  And, No, I cannot
 tell you the name of the company because of my fiduciary responsiblity
 to them.

 Richard Riehle
 richard@adaworks.com
 http://www.adaworks.com
 




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-26  0:00           ` Richard D Riehle
@ 1998-08-27  0:00             ` dennison
  0 siblings, 0 replies; 18+ messages in thread
From: dennison @ 1998-08-27  0:00 UTC (permalink / raw)


In article <6s1esj$3or@sjx-ixn2.ix.netcom.com>,
  Richard D Riehle <laoXhai@ix.netcom.com> wrote:
> In article <6s13q3$5v9$1@nnrp1.dejanews.com>,
> 	dennison@telepath.com wrote:
>
> In response to R.Riehle's earlier anecdote about conditional compilation
>
> >Can't you get the same effect by using a build tool like gnumake? Gnumake
> is
> >about as standard as they come. I'm pretty sure gnu has a pre-processor
> that
> >should be available on every platorm gnumake is as well.

>  This presumes the availability, 1) of gnu, 2) Ada 95.  The organization
>  mentioned in my post continues to use only Ada 83, as do many shops who

No. It has absolutely nothing to do with what version of Ada (or what vendor)
you happen to have.

>  continue to use Ada.  Also, gnumake is not universally available even
>  if an organization decides to use Ada 95.  In the case of the
>  development group I referenced, they are non-military, use Ada by

That is an issue. But to my knowledge there aren't a lot of development
platforms on which gnumake is unavailable. Personally, I don't know of one
development platform in that category that has an Ada compiler. On
Macintoshes I think you have to purchase a third party unix subsystem, so its
a bit iffy there. Are you at liberty to divulge that?


--
T.E.D.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-24  0:00   ` Mark A Biggar
@ 1998-08-27  0:00     ` Samuel T. Harris
  1998-08-27  0:00       ` David C. Hoos, Sr.
  0 siblings, 1 reply; 18+ messages in thread
From: Samuel T. Harris @ 1998-08-27  0:00 UTC (permalink / raw)


Mark A Biggar wrote:
> 
> Gene Ouye wrote:
> > Rex Reges wrote:
> > > I just saw some Ada95 code riddled with conditional
> > > compilation statements. I wasn't aware that this
> > > was part of Ada95 and I can't find it in the ARM.
> > > Is this some feature that compiler vendors have
> > > all decided to support?
> > Rational Apex includes a preprocessor that can be used for conditional
> > compilation, but this is certainly NOT something that the ARM requires,
> > and Ada compiler vendors are NOT required to provide it.  As far as I
> > know, the compiler vendors have not decided to support any particular
> > conditional compilation syntax much less conditional compilation in
> > general.
> 
> It should also be noted that most ANSI standard C compiler preprocessors
> will not work with Ada code.  The 2 languages have just enough differences
> in the way they break text up into tokens that a ANSI C preprocessor (whose
> operation is defined in terms of token strings not characters) gets
> very confused, especially about ' attributes.  Older pre-ANSI text based
> C preporcessors may work depending on how they habdle quoting.
> 
> --
> Mark Biggar
> mark.a.biggar@lmco.com

I'm afraid the original message has expired in my news server,
but I seem to remember the problem involved moving from VADS
to GNAT. It should be noted that the VADS a.app works with
or without a VADS library so the original poster could continue
using a.app as before and still use GNAT for the actual
compilation.

-- 
Samuel T. Harris, Principal Engineer
Raytheon Training Incorporated
"If you can make it, We can fake it!"




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-27  0:00     ` Samuel T. Harris
@ 1998-08-27  0:00       ` David C. Hoos, Sr.
  0 siblings, 0 replies; 18+ messages in thread
From: David C. Hoos, Sr. @ 1998-08-27  0:00 UTC (permalink / raw)



Samuel T. Harris wrote in message <35E58D2E.FD34A7DB@hso.link.com>...
<snip>
>I'm afraid the original message has expired in my news server,
>but I seem to remember the problem involved moving from VADS
>to GNAT. It should be noted that the VADS a.app works with
>or without a VADS library so the original poster could continue
>using a.app as before and still use GNAT for the actual
>compilation.
>
Or, if you don't mind a compiler-specific solution like a.app, then you can
use gnatprep for conditional compilation.

David C. Hoos, Sr.







^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Conditional Code in Ada 95?
  1998-08-25  0:00     ` Jean-Pierre Rosen
@ 1998-08-28  0:00       ` Laurent Pautet
  0 siblings, 0 replies; 18+ messages in thread
From: Laurent Pautet @ 1998-08-28  0:00 UTC (permalink / raw)


"Jean-Pierre Rosen" <rosen.adalog@wanadoo.fr> writes:
> 
> However, there is something that's damn close to it:
> 
> with Hardware_Specific_1;
> package Hardware_Specific renames Hardware_Specific_1;
> 
> and then use package Hardware_Specific all over the place. If you change
> hardware, there is one line to change in the whole program.

Well, that's not so easy. It could be quite difficult to maintain. It
could be very error-prone as well.

For a package with constant declarations, I think it is better to
generate it automatically (during configuration).

Concerning the code, for a package (which is a logical unit you don't
want to reorganize), you have to split it into a platform independent
part and N platform dependent parts. It's even worth when platforms
are really different (Windows vs Unix). A piece of code could be
identical on any Unix platform (so why would you duplicate it?) but
different on Windows. If you do this for several units, then it's a
lot of work and a lot of errors.

The trick you mentioned is used in the GNAT run-time. Robert can tell
us whether it is easy to maintain or not. I should admit that it won't
be easier to maintain it using conditional code. But if you look
closely to some low level parts of GNAT, there are written in C with
conditional code (OS_Lib for instance). So, both mechanisms are used.

I think there is no general solution and you should be allowed to use
package renaming, automatic code generation or conditional
code. Incidentally, I guess each compilor vendor has its own tool to
provide conditional code but as it is not standardized, it is not
portable.

-- 
-- Laurent




^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~1998-08-28  0:00 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-08-21  0:00 Conditional Code in Ada 95? Rex Reges
1998-08-21  0:00 ` Gene Ouye
1998-08-24  0:00   ` Mark A Biggar
1998-08-27  0:00     ` Samuel T. Harris
1998-08-27  0:00       ` David C. Hoos, Sr.
1998-08-22  0:00 ` Gautier.DeMontmollin
1998-08-23  0:00   ` dewar
1998-08-24  0:00     ` Gautier.DeMontmollin
1998-08-24  0:00   ` Michael F Brenner
1998-08-25  0:00     ` dewarr
1998-08-25  0:00       ` Richard D Riehle
1998-08-26  0:00         ` dennison
1998-08-26  0:00           ` Richard D Riehle
1998-08-27  0:00             ` dennison
1998-08-26  0:00       ` Michael F Brenner
1998-08-25  0:00     ` Jean-Pierre Rosen
1998-08-28  0:00       ` Laurent Pautet
1998-08-22  0:00 ` dewarr

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