A 子类型标记基本上是一个表示类型或子类型的名称(ARM 3.2.2(4))。 ARM使用的原因子类型标记整个过程都与一些神秘的区别有关(ARM 3.2.1);当你说type Foo is
你正在声明一个类型及其第一个亚型,以及名字Foo
指的是第一个子类型。
我认为你的问题是你有一个包裹Location
包含同名实体,这让编译器感到困惑。
你还没有提供完整的可编译代码示例,但是在应用@ajb的建议之后,我认为它会是这样的:
package Location is
type Location is record
Id : Positive;
X : Float;
Y : Float;
end record;
type Location_Acess is access all Location;
type Route is array (Positive range<>) of Location_Acess;
type Route_Acess is access all Route;
type Population is array (Positive range<>) of Route_Acess;
end Location;
with Location; use Location;
package Location_User is
Open_Route : Route(1..3) := (others => new Location'(X=>1.0,Y=>1.0, id=>1));
end Location_User;
编译器错误消息将是
location_user.ads:3:47: subtype mark required in this context
location_user.ads:3:47: found "Location" declared at location.ads:1
(看看它如何告诉你查看第 1 行location.ads
,包名?)
You could通过说来解决这个问题new Location.Location
,但是这样你就需要到处说这句话了。
有两种规范的解决方案,两个阵营的支持者之间存在宗教分歧。
第一个(我更喜欢的)是调用包Locations
并留下类型Location
, Route
, Population
像他们那样。
第二个(其中I考虑丑陋并且只会在迫切需要时使用)将用后缀装饰类型名称:
type Location_Type is
or
type Location_T is