comp.lang.ada
 help / color / mirror / Atom feed
From: stt@inmet.inmet.com
Subject: Re: Continued discussion of Ada compile
Date: 14 Sep 90 10:39:00 GMT	[thread overview]
Message-ID: <20600060@inmet> (raw)
In-Reply-To: 1732@dinl.mmc.UUCP


Re: Compilation speed, generics, etc.

There is nothing wrong with using generics "heavily" so long
as you realize that in most cases, they will be treated
roughly like an "include" or a macro expansion upon
instantiation.  Therefore, in calculating the number of
lines compiled, you should multiply the number of instantiations
of any generic by the number of lines of code in the generic
spec and body.

As far as recompiling the world, your problem seems to be
that the "specs" to your "core" are not sufficiently stable,
or that your "core" includes generic bodies mixed in with
non-generic code.
It is important to remember that, for most compilers,
instantiating a generic is analagous to "inlining" a
subprogram call.  Both create a dependence from the point of
instantiation/call on the *body* of the defining unit.
Generic instantiations can be particularly troublesome
since they are often themselves in a spec, and therefore
anything which depends on this spec, indirectly depends 
on the *body* of the generic.

There are various remedies.  Eventually, it is hoped that
most compilers will break this dependence on generic bodies,
by compiling the bodies of instantiations as implicitly separate 
compilation (sub)units.  However, until that is widespread,
you would do well to keep your generic bodies stable, or
only instantiate them in other bodies.  If you have
an instantiation in a "core" spec, you can instead
put a regular package spec there, and then implement
that package spec using an instantiation with a simple
layering (i.e., trivial subprogram bodies which just "pass the buck"
to the subprograms provided by a generic instantiation).

Similarly, avoid the use of pragma-Inline until the system
is debugged and stable.  Pragma Inline generally slows down
compiles, saves only a modest amount of run-time (in the "big"
picture), and creates recompilation nightmares.

Finally, once you have worked around the dangers of
generics and inlines, KEEP YOUR SPECS STABLE.  This
may mean providing extra "reserved" interfaces, escape
hatches, etc., to handle last-minute changes without
having to recompile "core" specs.
Once things are relatively debugged and stable, you should
eliminate the work-arounds.  Therefore, all work-arounds should
be visibly marked in the source.

Although the Rational is a great environment, it
definitely lulls people into forgetting about the
requirements of Ada compilers for "real" targets, where
due to optimization requirements, it is necessary to
expand generics inline, and it is not generally practical
to maintain enough of a program library database to support
incremental recompilation.

I hope this helps...

S. Tucker Taft      stt@inmet.inmet.com; uunet!inmet!stt
Intermetrics, Inc.
733 Concord Avenue
Cambridge, MA  02138

  reply	other threads:[~1990-09-14 10:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-09-13 22:09 Continued discussion of Ada compiler response query Eric Schallenmueller
1990-09-14 10:39 ` stt [this message]
1990-09-14 12:15 ` Robert Firth
1990-09-14 21:24   ` Eric Schallenmueller
replies disabled

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