comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: This can't be done in Ada...or?
Date: Thu, 17 Feb 2005 16:06:51 -0600
Date: 2005-02-17T16:06:51-06:00	[thread overview]
Message-ID: <Oa-dnapmurWIiIjfRVn-1w@megapath.net> (raw)
In-Reply-To: m3wttaciqw.fsf@0x53586c67.boanxx18.adsl-dhcp.tele.dk

"Mark Lorenzen" <mark.lorenzen@ofir.dk> wrote in message
news:m3wttaciqw.fsf@0x53586c67.boanxx18.adsl-dhcp.tele.dk...
> "Per Lindquist" <commander@death-star.com> writes:
...
> > Will your solution cause overhead for each subprogram call?
>
> A compile-time instantiation of a package has nothing to do with
> run-time efficiency. You can also define a new type in a subprogram,
> which doesn't affect run-time efficiency either.

That's sometimes true, but never on a compiler that code shared generics by
default (like Janus/Ada). And even on compilers that treat generics as
macros, it depends on the elaboration overhead. So it is a mistake to give
that as a general rule. Similarly, a type declared in a subprogram might or
might not have run-time overhead (it depends on what the elaboration of the
type does - if it depends on a parameter, for instance, there almost
certainly is some overhead).

Not having the code for the generic in question (I couldn't find any easy
way to see it on the PragmaARC site, and I didn't want to download the whole
thing), I can't say what overhead it has. Clearly there is some size
overhead, but that might not be much more than the size overhead of the
explicit constants.

Personally, I'd stick with the constants, because they can be tailored to
disambiguate overloaded subprograms, and there is no possibility of
overhead. But YMMV.

                   Randy Brukardt.

P.S. I don't find the "if" statements surrounding the tracing particularly
"yucky". Unless your system is rather small, you'll need a way to control
what is traced, and that can be combined into the if statement with no
overhead when the traces are all off. One way is to use an extra constant:

    if (not Tracing.No_Logging) and then Tracing.Log_This (Where => ...)
then
        Tracing.Log_Item (Where => ..., Item => "This is a log entry.");
    end if;

We use variations on this in the Janus/Ada compiler, the AdaIC web server,
the Trash Finder spam filter, and other tools. (Claw doesn't have any
built-in tracing; it's too intrusive.)

If you only need a variable to control tracing, you can change that to a
constant to get rid of all of the overhead and use if statements with a
single item:

    if Tracing.Log_Me then
       ...

This solution requires a bit more version control (which is outside of Ada,
of course), but it isn't bad.

                RLB






  parent reply	other threads:[~2005-02-17 22:06 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-11 16:33 This can't be done in Ada...or? Per Lindquist
2005-02-11 16:51 ` Duncan Sands
2005-02-12 19:55   ` Florian Weimer
2005-02-14  8:34     ` Per Lindquist
2005-02-14  8:17   ` Per Lindquist
2005-02-11 17:02 ` Jeff C
2005-02-11 18:27   ` Robert A Duff
2005-02-11 23:51     ` Ludovic Brenta
2005-02-11 23:52       ` Robert A Duff
2005-02-12 13:55     ` Duncan Sands
2005-02-12 14:58       ` Martin Krischik
2005-02-12 15:56         ` Martin Dowie
2005-02-12 19:02       ` Robert A Duff
2005-02-14  8:49     ` Per Lindquist
2005-02-11 17:08 ` Jerome Hugues
2005-02-14  9:05   ` Per Lindquist
2005-02-14 13:07     ` Georg Bauhaus
2005-02-12  1:10 ` Jeffrey Carter
2005-02-12 14:01   ` Duncan Sands
2005-02-13  0:27     ` Jeffrey Carter
2005-02-14  9:10       ` Per Lindquist
2005-02-15  0:40         ` Jeffrey Carter
2005-02-15  7:40           ` Per Lindquist
2005-02-15  8:39             ` OT: Google reply (Was: Re: This can't be done in Ada...or?) Adrien Plisson
2005-02-15  9:42               ` Per Lindquist
2005-02-15  8:27           ` This can't be done in Ada...or? Per Lindquist
2005-02-14 22:10             ` Manuel G. R.
2005-02-15  8:47             ` Mark Lorenzen
2005-02-15  9:09               ` Jacob Sparre Andersen
2005-02-15  9:31                 ` Mark Lorenzen
2005-02-15  9:48                   ` Jacob Sparre Andersen
2005-02-15 10:07                     ` Mark Lorenzen
2005-02-15 10:15                   ` Martin Dowie
2005-02-17 22:09                     ` Randy Brukardt
2005-02-18  6:53                       ` Martin Dowie
2005-02-15 13:46                   ` Robert A Duff
2005-02-15 13:41                 ` Robert A Duff
2005-02-15 16:30                   ` Per Lindquist
2005-02-15 19:38                     ` Martin Dowie
2005-02-15 20:20                     ` Robert A Duff
2005-02-17 21:52                   ` Simon Wright
2005-02-17 22:06               ` Randy Brukardt [this message]
2005-02-17 22:40                 ` Mark Lorenzen
2005-02-16  0:04             ` Jeffrey Carter
2005-02-16  0:09             ` Jeffrey Carter
2005-02-17  9:47               ` Per Lindquist
2005-02-17 22:36               ` Randy Brukardt
2005-02-14 15:21 ` Peter Amey
replies disabled

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