comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: on OO differnces between Ada95 and C++
Date: 1996/02/24
Date: 1996-02-24T00:00:00+00:00	[thread overview]
Message-ID: <dewar.825176840@schonberg> (raw)
In-Reply-To: 312C5160.41C6@Rational.COM

Jerome said, answering me:

> for Ada files, and GNAT does not require specs to be explicitly
> compiled

Even GNAT will perform a semantic analysis of Ada specs. Try to run a
C++ compiler against a .h file!

Absolutely true. I was using compiled here in the sense of creating an
object file.

GNAT does not create object files for:

  subunits
  generic units
  package specs that require a body

However, it is perfectly fine, and very useful, to be able to compile
all these kinds of units using the -gnatc swich that asks GNAT to
fully check the syntax and semantics. It is indeed an important advantage
of Ada that such checking is possible (you said "try to run a C++ compiler
against a .h file", and of course a similar suggestion is "try to run a
C++ compiler against a template". In Ada, the generic contract model means
that a generic body that compiles clean will always instantiate clean, but
that of course is not the case for C++ templates. It is true that you get
some extra flexibility in return for this freedom in C++, but for the
construction of large systems, the contract model is an important guarantee
(so important that it is the one place in Ada 95 where an incompatible
change was made to Ada 83 to fix up the one serious hole in the model,
namely the business of passing unconstrained types).

In a small program with GNAT, you don't need to bother to compile 
these non-object-producing units at all, since you will find the
errors immediately from the clients, and can then fix up whatever
needs fixing.

But in a large program, the ability to verify specs, subunits, and generics
independently is critical (and required by the RM), so there the use of
the -gnatc switch is very useful.

Note: if you attempt to compile any of the above units to produce object
files (by omitting the -gnatc), then an error is signalled:

  No code generated for file xxx (package spec)

or somesuch. The error message is needed (and the compiler will indicate
error status) because the expected object file is not produced. Actually
I think I wll change the message to

  No object file created for file xxx (...)

since that is clearer. 

If you find this confusing, just follow the proper procedure, which is
to use -gnatc when compiling a subunit, generic unit, or package spec.
Note also that -gnatc is useful when comilling a parent unit with subunits,
it checks the syntax and semantics JUST of the parent unit, without checking
the subunits.





  reply	other threads:[~1996-02-24  0:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-02-20  0:00 on OO differnces between Ada95 and C++ Nasser Abbasi
1996-02-20  0:00 ` Norman H. Cohen
1996-02-21  0:00   ` Mark A Biggar
1996-02-22  0:00     ` Norman H. Cohen
1996-02-27  0:00   ` Adam Morris
1996-02-20  0:00 ` Jerome Desquilbet
1996-02-21  0:00   ` Robert Dewar
1996-02-22  0:00     ` Jerome Desquilbet
1996-02-24  0:00       ` Robert Dewar [this message]
1996-02-22  0:00   ` Pete Becker
1996-02-23  0:00     ` Jerome Desquilbet
1996-02-26  0:00     ` Darren C Davenport
1996-02-26  0:00       ` Pete Becker
1996-02-27  0:00         ` Nigel Perry
1996-02-20  0:00 ` Robert I. Eachus
1996-02-21  0:00 ` Darren C Davenport
1996-02-21  0:00 ` John English
1996-02-22  0:00   ` Nasser Abbasi
1996-02-26  0:00     ` John English
1996-02-27  0:00       ` Dale Stanbrough
1996-02-22  0:00   ` Gene Ouye
1996-02-26  0:00     ` John English
1996-02-21  0:00 ` Jon S Anthony
  -- strict thread matches above, loose matches on Subject: below --
1996-02-21  0:00 Christian Jaensch, FRG
1996-02-26  0:00 Simon Johnston
replies disabled

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