5

How can I load two packages with the same name but located in seperate folders?

Example:

/src/alpha/foopackage.ads
/src/beta/foopackage.ads

I then would like to use foopackages using:

with alpha.foopackage; 
with beta.foopackage; 

Also, if you have any other tips about organizing projects in Ada please write. There is not much info about project organization in Ada on the net.

T.E.D.
  • 44,016
  • 10
  • 73
  • 134

2 Answers2

5

You've already solved the problem!

src/alpha/foopackage.ads contains:

package alpha.foopackage is

   ...

end alpha.foopackage;

while src/beta/foopackage.ads contains:

package beta.foopackage is

   ...

end beta.foopackage;

Now you will run into a temporary problem if you're using GNAT and its default naming convention. This naming convention requires that the files be named alpha-foopackage.ads and beta-foopackage.ads, respectively.

If you insist on using foopackage.ads as the filenames, this convention can be worked around. With GNAT, see Handling Arbitrary File Naming Conventions with gnatname, Using Other File Names, or Alternative File Naming Schemes.

TamaMcGlinn
  • 2,840
  • 23
  • 34
Marc C
  • 8,664
  • 1
  • 24
  • 29
4

This is almost a duplicate of the question which led to this answer.

However, there's another issue to do with naming, which is that GNAT (I think you are using GNAT?) has a default file naming convention (there are ways of overriding this convention, but you'd need a Good Reason to bother).

So your source files, whatever directory you choose to put them in, should be named alpha-foopackage.ads and beta-foopackage.ads respectively.

Community
  • 1
  • 1
Simon Wright
  • 25,108
  • 2
  • 35
  • 62