comp.lang.ada
 help / color / mirror / Atom feed
From: yoehoduv@protonmail.com
Subject: use type does not seem to work for types in generic package instantiations
Date: Tue, 18 Feb 2020 01:37:57 +0000
Date: 2020-02-18T01:37:57+00:00	[thread overview]
Message-ID: <r2ff61$1bl$1@neodomea5yrhcabc.onion> (raw)

It looks like use type has no effect when the type is from a package
declared in the same region as the use type statement.

I can make the primitive subprograms of a type directly visible with
`use all type` like this:

     package Type_Package is
        type T is null record;
        procedure Action(X: T) is null;
     end Type_Package;

     with Type_Package;
     procedure Use_Type is
        use all type Type_Package.T;
        X: Type_Package.T;
     begin
        Action(X);
     end Use_Type;

However, it does not seem to work when I move `Type_Package` inside
`Use_Type`.

     procedure Use_Type is
        package Type_Package is
           type T is null record;
           procedure Action(X: T) is null;
        end Type_Package;
        use all type Type_Package.T;
        X: Type_Package.T;
     begin
        Action(X);
     end Use_Type;

I get

     gcc -c use_type.adb
     use_type.adb:9:04: "Action" is not visible
     use_type.adb:9:04: non-visible declaration at line 4
     gnatmake: "use_type.adb" compilation error

The same thing occurs when I instantiate a generic package.  For
example, when I want to use the data types in `Ada.Containers`.

     package Element_Set is
        new Ada.Containers.Hashed_Sets(Element_Type, Hash, "=");
     use all type Element_Set.Set;

The `use type` clause here seems to have no effect.

Does anyone know why?

I originally posted this at
<https://stackoverflow.com/questions/60246613/how-to-use-a-type-from-a-child-package-generic-package-instantiation>

             reply	other threads:[~2020-02-18  1:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18  1:37 yoehoduv [this message]
2020-02-18  4:19 ` use type does not seem to work for types in generic package instantiations yoehoduv
replies disabled

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