Question

I tried searching a lot for what I thought was Nested Generic Packages, which I don't know how to implement in Ada. I found no helpful references or sources online of what I am trying to accomplish so please tell me if it's possible or other ways to accomplish it.

package AdjList is new List(Integer);
package Graph is new List(AdjList);

I am getting compilation errors for these 2 lines regarding the type I am passing to the List generic package.

I am trying to have 2 nested lists which will form a type of graph and I am forced to use this implementation approach. Any ideas/thoughts?

Was it helpful?

Solution

The error comes from the fact that you are passing AdjList, which is a package to the parameter. You need to pass a type that is the main data of that package.

package AdjList is new List(Integer);
package Graph is new List(AdjList.Data);   

OTHER TIPS

Depending on the compiler/how you have set up your development environment, you may want to make sure each of the package instantiations are in separate file (.ads files if you are using Gnat).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top