comp.lang.ada
 help / color / mirror / Atom feed
* Ada95 Package Bodies: Required?
@ 1996-05-02  0:00 Matt Hembree
  1996-05-02  0:00 ` Robert A Duff
  1996-05-02  0:00 ` Pat Rogers
  0 siblings, 2 replies; 3+ messages in thread
From: Matt Hembree @ 1996-05-02  0:00 UTC (permalink / raw)



Forgive me if I prove myself irreparably ignorant, but:

The document 'HOW TO PROGRAM IN Ada 9X, USING Ada 83', written by Erhard
Ploedereder, which I obtained from the Ada Information Clearinghouse
(AdaIC), says:

   "Guideline 8:  All library unit packages must have bodies,
    even if such bodies are empty."

The 'Ada Compatibility Guide', v. 6.0, 1 Jan 95, by Bill Taylor, which I
also got from the Ada Information Clearinghouse, says:

   "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."

What gives?  We are converting from Ada83 to Ada95, and this package
body issue may mean many (admittedly small) changes to our code.

=====================================================================
Matthew R. Hembree                          (817) 777-2738
Lockheed Martin Tactical Aircraft Systems
HembreeMR@cliffy.lfwc.lockheed.com




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Ada95 Package Bodies: Required?
  1996-05-02  0:00 Ada95 Package Bodies: Required? Matt Hembree
  1996-05-02  0:00 ` Robert A Duff
@ 1996-05-02  0:00 ` Pat Rogers
  1 sibling, 0 replies; 3+ messages in thread
From: Pat Rogers @ 1996-05-02  0:00 UTC (permalink / raw)



In <3188DE77.41C6@cliffy.lfwc.lockheed.com>, Matt Hembree <HembreeMR@cliffy.lfwc.lockheed.com> writes:
>Forgive me if I prove myself irreparably ignorant, but:
>
>The document 'HOW TO PROGRAM IN Ada 9X, USING Ada 83', written by Erhard
>Ploedereder, which I obtained from the Ada Information Clearinghouse
>(AdaIC), says:
>
>   "Guideline 8:  All library unit packages must have bodies,
>    even if such bodies are empty."
>
>The 'Ada Compatibility Guide', v. 6.0, 1 Jan 95, by Bill Taylor, which I
>also got from the Ada Information Clearinghouse, says:
>
>   "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."
>
>What gives?  We are converting from Ada83 to Ada95, and this package
>body issue may mean many (admittedly small) changes to our code.


Package bodies are indeed not allowed unless they are actually required.
Or, as Tucker put it, "That which is not required is forbidden!" :)
If you need the body for other reasons, I suggest pragma Elaborate_Body
which will make the body required.  (Or just declare a private subprogram
in the package declaration, to have a null body in the package body, but I
don't like that approach now that the pragma is available.)

BTW, I always go by what the RM says. :)

pat
---------------
Patrick Rogers
progers@acm.org





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Ada95 Package Bodies: Required?
  1996-05-02  0:00 Ada95 Package Bodies: Required? Matt Hembree
@ 1996-05-02  0:00 ` Robert A Duff
  1996-05-02  0:00 ` Pat Rogers
  1 sibling, 0 replies; 3+ messages in thread
From: Robert A Duff @ 1996-05-02  0:00 UTC (permalink / raw)



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




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-05-02  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-05-02  0:00 Ada95 Package Bodies: Required? Matt Hembree
1996-05-02  0:00 ` Robert A Duff
1996-05-02  0:00 ` Pat Rogers

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