comp.lang.ada
 help / color / mirror / Atom feed
* Ada 95 Compatibility
@ 1996-02-22  0:00 John Herro
  1996-02-22  0:00 ` Mark A Biggar
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: John Herro @ 1996-02-22  0:00 UTC (permalink / raw)


     In Ada 95, a package spec. that doesn't *need* an corresponding body
can't *have* one.  Here's a simplified program segment that I wrote in Ada
83:

package P is
   Buffer : array(1 .. 50) of Integer;
end P;

package body P is
begin
   -- code to initialize Buffer
end P;

     The buffer initialization is too complicated to do by initializing to
an aggregrate in the package spec., such as one would do if initializing
the buffer to all zeros.  Here's how I rewrote the code for Ada 95; I'm
wondering if I did it the best way:

package P is
   Buffer : array(1 .. 50) of Integer;
private
   procedure Init;
end P;

package body P is
   procedure Init is separate;
begin
   Init;
end P;

separate (P)
procedure Init is
begin
   -- code to initialize Buffer
end Init;

     There are other ways I could have done it.  I could have made
procedure Init public and required the main program to call it, but that
sounds worse to me.  I could have omitted the declaration of Init and
instead declared procedure Dummy that does nothing but give me the
opportunity to create a package body.  The package body would contain
"procedure Dummy is begin null; end Dummy;" which would never be called,
and the package body would initialize Buffer just as in the Ada 83
example.  This, too, seems worse than what I did.  However, what I did in
Ada 95 seems like a lot more lines of code that the Ada 83 version.  Do
you guys think I rewrote it the best way, or do you have other
suggestions?  Thanks.
- John Herro
Software Innovations Technology
http://members.aol.com/AdaTutor
ftp://members.aol.com/AdaTutor




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

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

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-02-22  0:00 Ada 95 Compatibility John Herro
1996-02-22  0:00 ` Mark A Biggar
1996-02-23  0:00   ` PHILIP W. BRASHEAR
1996-02-23  0:00 ` Ken Garlington
1996-02-24  0:00   ` John Herro
1996-02-24  0:00     ` Robert Dewar
1996-02-26  0:00       ` Ken Garlington
1996-02-26  0:00         ` Robert Dewar
1996-02-26  0:00         ` Robert Dewar
1996-02-23  0:00 ` Keith Thompson
1996-02-23  0:00 ` Peter Amey

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