comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Ada95 Package Bodies: Required?
Date: 1996/05/02
Date: 1996-05-02T00:00:00+00:00	[thread overview]
Message-ID: <DqsHoo.Dw2@world.std.com> (raw)
In-Reply-To: 3188DE77.41C6@cliffy.lfwc.lockheed.com


In article <3188DE77.41C6@cliffy.lfwc.lockheed.com>,
Matt Hembree  <HembreeMR@cliffy.lfwc.lockheed.com> wrote:
>   "Guideline 8:  All library unit packages must have bodies,
>    even if such bodies are empty."

This is probably based on an earlier version of Ada 9X, which required
a body for every library package.

>   "28.   Library Package Bodies Illegal if not Required"  and
>
>   "In Ada95, it is illegal to providea body for a library
>    package that does not require one."

This is correct.  The rule was changed during the design of Ada 9X, in
order to increase upward compatibility.

You should simply obey the Ada 95 rule in your Ada 83 code: make a
package body if and only if you have a package that requires a body
(e.g. because it contains a procedure that needs a body).  If you want a
body that's not otherwise required, you can put something in the spec
that makes the body mandatory.  For example:

    package P is
        A: array(Character) of Character;
        -- No subprograms here.
    private
        type Require_Body;
    end P;

    package body P is
        type Require_Body is record null; end record;
    begin
        for I in A'Range loop
            A(I) := To_Upper(I);
        end loop;
    end P;

This is a good idea in Ada 83 anyway, since without the Require_Body,
you might forget to recompile P's body, and many compilers will then
silently omit the initialization of A.

If you're writing Ada 83 code, it's also a good idea to compile it with
an Ada 95 compiler once in a while, even if there's no Ada 95 compiler
for your target, just to catch any possible incompatibilities.  There
aren't very many -- Ada 95 is *very* close to being purely upward
compatible with Ada 83.  The only one I've noticed in any real code is
the fact that type Character changed from 7-bit Ascii to the 8-bit ISO
standard.  In practise, there are more incompatibilities between any two
Ada 83 compilers, than between Ada 83 and Ada 95.

- Bob




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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-05-02  0:00 Ada95 Package Bodies: Required? Matt Hembree
1996-05-02  0:00 ` Robert A Duff [this message]
1996-05-02  0:00 ` Pat Rogers
replies disabled

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