comp.lang.ada
 help / color / mirror / Atom feed
From: "Alejandro R. Mosteo" <alejandro@mosteo.com>
Subject: Referring to the instance of a generic parent package
Date: Wed, 23 Oct 2019 14:54:38 +0200
Date: 2019-10-23T14:54:38+02:00	[thread overview]
Message-ID: <qopiif$1fq$1@dont-email.me> (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.


             reply	other threads:[~2019-10-23 12:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23 12:54 Alejandro R. Mosteo [this message]
2019-10-23 15:55 ` Referring to the instance of a generic parent package 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
replies disabled

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