comp.lang.ada
 help / color / mirror / Atom feed
* Referring to the instance of a generic parent package
@ 2019-10-23 12:54 Alejandro R. Mosteo
  2019-10-23 15:55 ` Jeffrey R. Carter
  2019-10-23 16:29 ` Shark8
  0 siblings, 2 replies; 6+ messages in thread
From: Alejandro R. Mosteo @ 2019-10-23 12:54 UTC (permalink / raw)


I have the following situation:

    generic
    package Parent is ... end Parent;

    generic
       with package P is new Parent (<>);
    package Sibling is ... end Sibling;

    generic
    package Parent.Child is

       package A_Sibling is new Sibling (Parent);
       --  Works in GNAT CE 2019
       --  Error in FSF 7.4:
       --    "Expect package instance to instantiate formal"

    end Parent.Child

Now, since CE is more recent, I guess that's the correct one. Still, this 
made me think about name resolution inside a generic child. My guess is 
that actual instances take precedence, since a non-instance one can be 
prefixed with standard:

    generic
    package Parent.Child

       Standard.Parent -- Refers to the non-instance
       Parent          -- Refers to the parent instance

    end Parent.Child;

My cursory searching to look for relevant rules has been unsuccessful, I 
guess because I'm not finding the proper keywords. Assuming the above 
assumption is correct, I would like to make the initial hierarchy work in 
the FSF version too. I can of course make Child a non-child of Parent and 
also receive Parent as a generic formal. The question is, would there be 
another way of referring to a child's parent instance from the child? I 
tried this:

    generic
    package Parent.Child is

       package Renamed_Parent renames Parent;
       -- Works in FSF, but I guess that's not using the instance because:

       package A_Sibling is new Sibling (Renamed_Parent);
       -- Error: "actual parameter must be instance of Parent"

The whole issue is not critical; I'm just generally curious. I'm 
experimenting with heavily nested generic child hierarchies and finding 
lots of corner cases (and visibility bugs).

Cheers,
Álex.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-10-24 16:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23 12:54 Referring to the instance of a generic parent package Alejandro R. Mosteo
2019-10-23 15:55 ` Jeffrey R. Carter
2019-10-24  9:42   ` Alejandro R. Mosteo
2019-10-23 16:29 ` Shark8
2019-10-24  9:35   ` Alejandro R. Mosteo
2019-10-24 16:26     ` Optikos

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