comp.lang.ada
 help / color / mirror / Atom feed
* Newbie question on child packages
@ 2002-10-09 15:52 Justin Birtwell
  2002-10-09 16:12 ` Matthew Heaney
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Justin Birtwell @ 2002-10-09 15:52 UTC (permalink / raw)


Hello all,

I'm trying to figure out how to create and use child packages.  Here's what
I've got so far.

Top level, empty parent package....JB.ads
package JB is
    --empty
end JB;

A child package spec called A.ads
package JB.A is
.........
end JB.A;

A child package body called A.adb
package body JB.A is
    <code>
end JB.A;

Here's my problem.  When I go to compile and build A I get an error from
A.adb "file jb-A.ads not found".  I made sure to compile A.ads but I'm still
getting the same error.  All the files are in the same folder.  Do I have to
change the name of A.ads to JB.A.ads?  or JB-A.ads?  This seems to defeat
the whole point of modularity and independence?

Please help.  I've read the chapters on Packages and Child packages in
Programming Ada 95 and the documentation at
http://www.it.bton.ac.uk/staff/je/adacraft but alas no help here.

Thanks,
Justin





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

* Re: Newbie question on child packages
  2002-10-09 15:52 Newbie question on child packages Justin Birtwell
@ 2002-10-09 16:12 ` Matthew Heaney
  2002-10-09 16:20   ` Justin Birtwell
  2002-10-09 16:18 ` Jim Rogers
  2002-10-09 16:43 ` tmoran
  2 siblings, 1 reply; 10+ messages in thread
From: Matthew Heaney @ 2002-10-09 16:12 UTC (permalink / raw)



"Justin Birtwell" <jbirtwell@yahoo.com> wrote in message
news:OgYo9.40823$Oa1.39958@nwrddc02.gnilink.net...
>
> Top level, empty parent package....JB.ads
> package JB is
>     --empty
> end JB;

You should mark this as a "pure" package:

package JB is
   pragma Pure;
end;

> A child package spec called A.ads
> package JB.A is
> .........
> end JB.A;

The mapping of file names to compilation units is compiler-specific.  If
you're using GNAT, for example, then this file would need to be named
jb-a.ads.

(However, if you're using GNAT, it should have given you a warning when you
tried to compile the spec.)

> A child package body called A.adb
> package body JB.A is
>     <code>
> end JB.A;

In GNAT, this needs to be named jb-a.adb.

> Here's my problem.  When I go to compile and build A I get an error from
> A.adb "file jb-A.ads not found".  I made sure to compile A.ads but I'm
still
> getting the same error.  All the files are in the same folder.  Do I have
to
> change the name of A.ads to JB.A.ads?  or JB-A.ads?

The latter.






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

* Re: Newbie question on child packages
  2002-10-09 15:52 Newbie question on child packages Justin Birtwell
  2002-10-09 16:12 ` Matthew Heaney
@ 2002-10-09 16:18 ` Jim Rogers
  2002-10-09 19:16   ` Simon Wright
  2002-10-09 16:43 ` tmoran
  2 siblings, 1 reply; 10+ messages in thread
From: Jim Rogers @ 2002-10-09 16:18 UTC (permalink / raw)


Justin Birtwell wrote:

> Hello all,
> 
> I'm trying to figure out how to create and use child packages.  Here's what
> I've got so far.
> 
> Top level, empty parent package....JB.ads
> package JB is
>     --empty
> end JB;
> 
> A child package spec called A.ads
> package JB.A is
> .........
> end JB.A;
> 
> A child package body called A.adb
> package body JB.A is
>     <code>
> end JB.A;
> 
> Here's my problem.  When I go to compile and build A I get an error from
> A.adb "file jb-A.ads not found".  I made sure to compile A.ads but I'm still
> getting the same error.  All the files are in the same folder.  Do I have to
> change the name of A.ads to JB.A.ads?  or JB-A.ads?  This seems to defeat
> the whole point of modularity and independence?
> 
> Please help.  I've read the chapters on Packages and Child packages in
> Programming Ada 95 and the documentation at
> http://www.it.bton.ac.uk/staff/je/adacraft but alas no help here.


You are encountering a GNAT file naming convention. Read the GNAT
documentation for full details.

GNAT requires the file name for a package spec or body to be related to
the actual name of the spec or body. It has well defined default rules for
this naming.

Given your package hierarchy your file names should be:

JB.ads
JB-A.ads
JB-A.adb

This does not interfere with either modularity or independence. It does
help the compiler find the files it needs to build your program. Other
compilers use a file registration scheme instead of a specific naming
convention. In practice a team will always establish a file naming
convention. Failure to do so will result in massive configuration and
maintenance issues. Given this reality, the GNAT scheme is quite
reasonable.

Jim Rogers






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

* Re: Newbie question on child packages
  2002-10-09 16:12 ` Matthew Heaney
@ 2002-10-09 16:20   ` Justin Birtwell
  2002-10-09 16:54     ` Matthew Heaney
  2002-10-09 18:45     ` Preben Randhol
  0 siblings, 2 replies; 10+ messages in thread
From: Justin Birtwell @ 2002-10-09 16:20 UTC (permalink / raw)


Thanks,  It worked!  does the pragma Pure allow me to not specifically
prefix all the child packages with 'jb'?





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

* Re: Newbie question on child packages
  2002-10-09 15:52 Newbie question on child packages Justin Birtwell
  2002-10-09 16:12 ` Matthew Heaney
  2002-10-09 16:18 ` Jim Rogers
@ 2002-10-09 16:43 ` tmoran
  2 siblings, 0 replies; 10+ messages in thread
From: tmoran @ 2002-10-09 16:43 UTC (permalink / raw)


> A child package spec called A.ads
> package JB.A is
> ...
> Here's my problem.  When I go to compile and build A I get an error from
> A.adb "file jb-A.ads not found".
> ...
> change the name of A.ads to JB.A.ads?  or JB-A.ads?
  Given the error message, it seems not unreasonable to guess the compiler
wants you to change the name to JB-A.ads

> This seems to defeat the whole point of modularity and independence?
  Hardly.  Would you be happy if the compiler searched every file on your
LAN to find one that contained "package JB.A"?  Some compilers, having
been told to compile "A.ads" will note in some kind of database that it
contains the spec of JB.A, so they can quickly find it in the future.
Some compilers don't do that and insist on a particular naming convention
so they can find the file of interest without a search.  If you are using
Gnat, it can be run either with its standard naming or you can give it a
name-file lookup table.  A third option is to run gnatchop to create files
with its naming convention from files named arbitrarily.

> Please help.  I've read the chapters on Packages and Child packages in
> Programming Ada 95 and the documentation at
> http://www.it.bton.ac.uk/staff/je/adacraft but alas no help here.
  Those documents talk about the Ada language, ie, the content of the
files.  It's purely the particular compiler's and OS's business how Ada
source code is to be stored in particular files in certain folders.  A
particular compiler could insist that source code be in 16 bit Unicode in
pgp signed files before it would compile, and that wouldn't violate any
Ada standard.  So you'll have to read the docs for your particular compiler.



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

* Re: Newbie question on child packages
  2002-10-09 16:20   ` Justin Birtwell
@ 2002-10-09 16:54     ` Matthew Heaney
  2002-10-09 18:45     ` Preben Randhol
  1 sibling, 0 replies; 10+ messages in thread
From: Matthew Heaney @ 2002-10-09 16:54 UTC (permalink / raw)



"Justin Birtwell" <jbirtwell@yahoo.com> wrote in message
news:TGYo9.41836$Mw4.34226@nwrddc01.gnilink.net...
> Thanks,  It worked!  does the pragma Pure allow me to not specifically
> prefix all the child packages with 'jb'?

No. It's there because of package elaboration issues.

In general, you should mark the "categorization" of packages, using the
strongest categorization possible:

pragma Pure;
pragma Preelaborate;
pragma Elaborate_Body;







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

* Re: Newbie question on child packages
  2002-10-09 16:20   ` Justin Birtwell
  2002-10-09 16:54     ` Matthew Heaney
@ 2002-10-09 18:45     ` Preben Randhol
  1 sibling, 0 replies; 10+ messages in thread
From: Preben Randhol @ 2002-10-09 18:45 UTC (permalink / raw)


Justin Birtwell wrote:
> Thanks,  It worked!  does the pragma Pure allow me to not specifically
> prefix all the child packages with 'jb'?

No. But you should let them have the prefix. Then it is much easier to
find the correct file when you need to edit your child packages later.

Look at my files:

gac.ads
gac-callbacks.adb
gac-callbacks.ads
gac-dialog-about.adb
gac-dialog-about.ads
gac-dialog.adb
gac-dialog.ads
gac-dialog-exceptions.adb
gac-dialog-exceptions.ads
gac-dialog-info.adb
gac-dialog-info.ads
gac-dialog-unsaved.adb
gac-dialog-unsaved.ads
gac-intl.adb
gac-intl.ads
gdialog.adb

Gac (GtkAda Composites) is the parent package. Now if I want to edit my
info dialog it is easy to figure out which file it is. 

Preben
-- 
Ada95 is good for you.
http://libre.act-europe.fr/Software_Matters/02-C_pitfalls.pdf



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

* Re: Newbie question on child packages
  2002-10-09 16:18 ` Jim Rogers
@ 2002-10-09 19:16   ` Simon Wright
  2002-10-09 21:06     ` Stephen Leake
  0 siblings, 1 reply; 10+ messages in thread
From: Simon Wright @ 2002-10-09 19:16 UTC (permalink / raw)


Jim Rogers <jimmaureenrogers@worldnet.att.net> writes:

> Given your package hierarchy your file names should be:
> 
> JB.ads
> JB-A.ads
> JB-A.adb

If you were on a Unix machine you would find that those names should be

jb.ads
jb-a.ads
jb-a.adb

I don't understand why people must put file names in ALL-CAPS!!! or
even Title-Case, come to that.



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

* Re: Newbie question on child packages
  2002-10-09 19:16   ` Simon Wright
@ 2002-10-09 21:06     ` Stephen Leake
  2002-10-11  5:00       ` Simon Wright
  0 siblings, 1 reply; 10+ messages in thread
From: Stephen Leake @ 2002-10-09 21:06 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> I don't understand why people must put file names in ALL-CAPS!!! 

Beats me. I guess they want to be like DOS. Hmm, I think VMS file
names are all uppercase (it's been a long time since I used VMS).

> or even Title-Case, come to that.

I use that for important files (like Makefile, Readme), since any
_real_ IDE* will display those in proper ASCII order, at the top of a
directory listing.

*Emacs, for example :).

-- 
-- Stephe



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

* Re: Newbie question on child packages
  2002-10-09 21:06     ` Stephen Leake
@ 2002-10-11  5:00       ` Simon Wright
  0 siblings, 0 replies; 10+ messages in thread
From: Simon Wright @ 2002-10-11  5:00 UTC (permalink / raw)


Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:

> Simon Wright <simon@pushface.org> writes:

> > or even Title-Case, come to that.
> 
> I use that for important files (like Makefile, Readme), since any
> _real_ IDE* will display those in proper ASCII order, at the top of
> a directory listing.

Yes, I forgot them. I suppose if you haven't been using a Unix system
for the last n years, you will apply the same rules to your important
Ada source too.



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

end of thread, other threads:[~2002-10-11  5:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-09 15:52 Newbie question on child packages Justin Birtwell
2002-10-09 16:12 ` Matthew Heaney
2002-10-09 16:20   ` Justin Birtwell
2002-10-09 16:54     ` Matthew Heaney
2002-10-09 18:45     ` Preben Randhol
2002-10-09 16:18 ` Jim Rogers
2002-10-09 19:16   ` Simon Wright
2002-10-09 21:06     ` Stephen Leake
2002-10-11  5:00       ` Simon Wright
2002-10-09 16:43 ` tmoran

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