Let's say I have a generic vector library. To make it easier to use, I want to instantiate various common forms of the vector library and make them visible in a single package.
I'm trying this:
with GenericVector;
package Vectors is
package Vectors3 is new GenericVector(3);
use all type Vectors3.Vector;
subtype Vector3 is Vectors3.Vector;
package Vectors4 is new GenericVector(4);
use all type Vectors4.Vector;
subtype Vector4 is Vectors4.Vector;
end;
The end goal is that I want to be able to do with Vectors; use Vectors;
and end up with Vector3
and Vector4
types directly available which Just Work.
Naturally, the code above doesn't work. It looks like the use all type
statements import the definitions attached to the specified type into the package specification but then those definitions aren't exported to the user of Vectors
. I have to do with Vectors; use Vectors; use all type Vectors.Vectors3;
instead. This is kind of sucky.
How can I do this?
You could simply make Vector3
and Vector4
new types, and not just subtypes. That would implicitly declare all the inherited, primitive operations from GenericVector
in Vectors
.