comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <marin.condic.auntie.spam@pacemicro.com>
Subject: Re: Implementing C/C++ style #include...
Date: Mon, 26 Mar 2001 14:35:25 -0500
Date: 2001-03-26T19:35:34+00:00	[thread overview]
Message-ID: <99o5m6$6of$1@nh.pace.co.uk> (raw)
In-Reply-To: u7l1cgzpa.fsf@gsfc.nasa.gov

Well, you bring up a lot of points here. Let me see if I can at least hit on
the overall cases.

Yes, I've seen cases where you may need to maintain code for two different
compilers. You can't sneak the one version of code past the other compiler,
so you might be tempted to use preprocessing directives to eliminate it.
(Something that is itself possibly peculiar to one compiler and won't sneak
past another compiler, eh?) Why can't you burry this in a package body that
is maintained down a separate CM path? (Your example could be hidden in a
package body, no?)

While I admit the possibility of maintaining code for two different
compilers, I think it is kind of rare. More likely, you've got code for two
different platforms wherein some resources may be variant between the
platforms. (OS calls, devices, etc.) In either case, I'd prefer to either
isolate it in a package body and maintain two bodies down two different CM
paths or I'd control it with (static or dynamic) "if" checking that I would
change from a configuration package spec. I'd personally prefer these
choices to using a preprocessor.

As for being "open" - I think it was G. K. Chesterton who said "Having an
open mind is nothing. The object of opening the mind, as of opening the
mouth, is to shut it again on something solid." :-) Seriously, I've used
preprocessors (and still do by way of C/C++) and just remain unconvinced
that you can't get there by other means with fewer pitfalls.

Given the experience I have had, I just don't see it as being in the same
category as "Unchecked_Conversion" and I don't feel the need for that sort
of "expressive power". Some people may like a preprocessor and that's fine
by me. I personally would advise against it.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/



"Stephen Leake" <stephen.a.leake.1@gsfc.nasa.gov> wrote in message
news:u7l1cgzpa.fsf@gsfc.nasa.gov...
> "Marin David Condic" <marin.condic.auntie.spam@pacemicro.com> writes:
>
> > I guess I've just seen it done enough different ways that work as well
or
> > better that I don't really see any necessity for a preprocessor to do
this
> > job. Managing different configurations can be handled with package body
> > substitution, static elimination of code via normal "if" statements,
pragma
> > Debug, available configuration management tools, etc.
>
> Not this one:
>
>    function Ada_Size_Of_Input is new
>       Interfaces_C_More.Storage_Unit_Size_Of (Input_Type);
> #if GNAT_Compiler
>    pragma Export (C, Ada_Size_Of_Input,
>                   "ball_ct633_ada_size_of_input",
>                   "ball_ct633_ada_size_of_input");
> #elsif ObjectAda_Compiler
>    pragma Export (DLL_STDCALL, Ada_Size_Of_Input,
>                   "ball_ct633_ada_size_of_input",
>                   "ball_ct633_ada_size_of_input");
> #end if;
>
> The difference is in the name of the Convention. Preprocessing is, in
> this case, the best way to handle it. I believe the only alternative
> is to reproduce the entire package spec, and change this one value.
> Surely you do not claim that is better from a maintenance point of
> view?
>
> I can only assume you have not personally encountered a situation like
> this. Until you have, you need to be a little more open :).
>
> There are similar examples of needing to support a mix of Ada 83/95,
> compiler vendors, and targets, where limited, structured,
> well-designed use of pre-processing is the best way to go.
>
> > As a result, I think that trying to include special pre-processor
> > directives in the source and going through an extra pre-compilation
> > step (fraught with peril!) is unnecessary and potentially dangerous.
>
> "potentially dangerous" yes, just like Unchecked_Conversion and
> Unchecked_Deallocation. "unecessary" no, just like
> Unchecked_Conversion and Unchecked_Deallocation!
>
> >
> > (Try looking at some older C code that may have very convoluted
> > "#include" chains, etc. if you need an example of how dangerous this
> > can get.) I've never once seen a case where you could accomplish
> > some goal with a preprocessor that you couldn't accomplish with a
> > less error prone technique.
>
> Have you seen the above case?
>
> > So why ask for the trouble?
>
> I'm not asking for "trouble", I'm asking for "expressive power".
> "Trouble" I can handle with coding guidelines and project discipline.
>
> Note that the gnat preprocessor does _not_ define "include", only
> "if". And it does _not_ define macros.
>
> --
> -- Stephe





  parent reply	other threads:[~2001-03-26 19:35 UTC|newest]

Thread overview: 115+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-13 18:37 Better support for garbage collection Nick Roberts
2001-03-14  8:16 ` Florian Weimer
2001-03-14 18:52   ` Robert A Duff
2001-03-14 19:40     ` Florian Weimer
2001-03-15 13:18       ` Nick Roberts
2001-03-14 19:29 ` Robert A Duff
2001-03-14 20:59   ` Brian Rogoff
2001-03-16 16:42     ` Robert A Duff
2001-03-17  6:13       ` Lao Xiao Hai
2001-03-24  4:08       ` Brian Rogoff
2001-03-15  4:35   ` Nick Roberts
2001-03-15 21:37     ` Randy Brukardt
2001-03-15 22:36     ` Stephen Leake
2001-03-16 16:26     ` Robert A Duff
2001-03-16 16:59       ` Brian Rogoff
2001-03-16 17:31         ` Robert A Duff
2001-03-16 18:29           ` Brian Rogoff
2001-03-17  2:30           ` Nick Roberts
2001-03-17 21:59             ` Robert A Duff
2001-03-17 22:57             ` Static typing (Was Re: Better support for garbage collection) Brian Rogoff
2001-03-17 23:45               ` Robert A Duff
2001-03-18  0:58                 ` Brian Rogoff
2001-03-19 15:24                   ` Robert A Duff
2001-03-20  4:21                     ` Brian Rogoff
2001-03-21  1:32                       ` Ken Garlington
2001-03-21 13:28                         ` Robert A Duff
2001-03-22  2:08                           ` Ken Garlington
2001-03-22 16:40                             ` Robert A Duff
2001-03-25 16:21                               ` Ken Garlington
2001-03-25 16:56                                 ` Ken Garlington
2001-03-25 22:31                                 ` Robert A Duff
2001-03-27  0:24                                   ` Ken Garlington
2001-03-28 23:15                                     ` Robert A Duff
2001-03-29  5:02                                       ` Ken Garlington
2001-03-29  6:13                                         ` David Starner
2001-03-29 10:10                                           ` AG
2001-03-29 14:28                                           ` Ken Garlington
2001-03-29 23:46                                         ` Robert A Duff
2001-03-30  3:41                                           ` Ken Garlington
2001-03-30 21:21                                             ` Robert A Duff
2001-03-31 19:30                                               ` Ken Garlington
2001-04-02 15:27                                                 ` Robert A Duff
2001-04-02 23:29                                                   ` Ken Garlington
2001-03-30 21:29                                             ` Robert A Duff
2001-03-30  9:16                                           ` Dmitry Kazakov
2001-03-30  9:51                                             ` Florian Weimer
2001-04-02  8:54                                               ` Dmitry Kazakov
2001-03-30 16:13                                             ` Ken Garlington
2001-04-02 11:00                                               ` Dmitry Kazakov
2001-03-30 20:44                                             ` Robert C. Leif, Ph.D.
2001-04-02 11:29                                               ` Dmitry Kazakov
2001-04-02 13:15                                                 ` Robert A Duff
2001-04-03  8:57                                                   ` Dmitry Kazakov
2001-03-27  2:39                             ` Andrew Berg
2001-03-27  3:33                               ` Ken Garlington
2001-03-27 14:23                                 ` Robert A Duff
2001-03-27 23:36                                   ` Ken Garlington
2001-03-29 23:50                       ` Robert A Duff
2001-03-19 18:24       ` Better support for garbage collection Tucker Taft
     [not found]   ` <87bsr46kxv.fsf@deneb.enyo.de>
2001-03-15 14:18     ` Robert A Duff
2001-03-15 16:36       ` Florian Weimer
2001-03-14 22:05 ` Laurent Guerby
2001-03-16 16:47   ` Robert A Duff
2001-03-16 19:46     ` Laurent Guerby
2001-03-16 20:10       ` Robert A Duff
2001-03-17 13:14         ` Support for per allocation pool selection (was: Better support for garbage collection) Laurent Guerby
2001-03-17 17:06           ` Robert A Duff
2001-03-17 19:19           ` Florian Weimer
2001-03-17 21:10             ` Robert A Duff
2001-03-15 17:56 ` Better support for garbage collection Ray Blaak
2001-03-21 16:15 ` Implementing C/C++ style #include bhazzard
2001-03-21 16:45   ` Marin David Condic
2001-03-22 15:13     ` Ira D. Baxter
2001-03-22 15:23       ` Marin David Condic
2001-03-25 15:45         ` Anton Gibbs
2001-03-26 14:24           ` Ted Dennison
2001-03-26 15:00             ` Marin David Condic
2001-03-26 14:49           ` Marin David Condic
2001-03-26 18:19             ` Stephen Leake
2001-03-26 18:44               ` Pascal Obry
2001-03-26 21:44                 ` Robert A Duff
2001-03-27  3:02                   ` Andrew Berg
2001-03-27  3:27                     ` Phaedrus
2001-03-27 17:41                   ` Pascal Obry
2001-03-26 19:18               ` Ted Dennison
2001-03-27 18:51                 ` Anton Gibbs
2001-03-26 19:35               ` Marin David Condic [this message]
2001-03-26 23:04                 ` Mark Lundquist
2001-03-27 14:38                   ` Marin David Condic
2001-03-26 16:12           ` Florian Weimer
2001-03-26 17:34             ` David Starner
2001-03-26 22:25               ` Florian Weimer
2001-03-27  3:29                 ` David Starner
2001-03-26 18:23             ` Stephen Leake
2001-03-26 22:34               ` Florian Weimer
2001-03-27  7:34         ` Ole-Hjalmar Kristensen
2001-03-27 12:43           ` Dale Stanbrough
2001-03-27 14:40             ` Marin David Condic
2001-03-27 15:01             ` Ted Dennison
2001-03-27 13:20           ` Preben Randhol
2001-03-23 17:39       ` Wes Groleau
2001-03-21 18:07   ` Mark Lundquist
2001-03-22 12:50   ` Chris M. Moore
2001-03-22 14:30     ` Marin David Condic
2001-03-22 21:15       ` singlespeeder
2001-03-22 21:42         ` Marin David Condic
2001-03-23 14:43           ` Georg Bauhaus
2001-03-23 18:51             ` Marin David Condic
2001-03-22 15:02     ` Pat Rogers
2001-03-22 15:28       ` Marin David Condic
2001-03-22 16:32       ` Chris M. Moore
2001-03-22 16:57       ` Robert A Duff
2001-03-26 16:13   ` Martin Dowie
2001-03-26 22:55   ` Phaedrus
2001-03-27  1:36     ` tmoran
replies disabled

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