comp.lang.ada
 help / color / mirror / Atom feed
From: "Adam Beneschan" <adam@irvine.com>
Subject: Re: Stupid question
Date: 13 Apr 2007 08:35:53 -0700
Date: 2007-04-13T08:35:53-07:00	[thread overview]
Message-ID: <1176478553.026938.254630@n59g2000hsh.googlegroups.com> (raw)
In-Reply-To: <1pyl2asiynhjs.117mopb54gcj7$.dlg@40tude.net>

On Apr 13, 1:20 am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:

> Are you saying that it is illegal to refer to generic children of generic
> packages as generic packages? I don't see where 12.7 states it. 12.7(4):
>
> "The generic_package_name shall denote a generic package (the template for
> the formal package); the formal package is an instance of the template."
>
> A.B is definitely a generic package to me.

Go back to 4.1.3.  When you're specifying an expanded name, you can't
use a prefix unless the prefix denotes a package, or an enclosing
named construct.  The prefix, here, "A", is not a package---it's a
generic.  And certainly you should know that you can't refer to things
inside a generic (except from inside that generic).  Suppose that,
instead of making B a child unit, you had nested it inside A:

   generic
   package A is
      A1 : Integer;
      generic
      package B is
      end B;
   end A;

Now, outside the declaration or body of A, you can't refer to "A.B"
any more than you can refer to "A.A1".  You need an instance to refer
to either one, i.e. A_Inst.B or A_Inst.A1.  Basically, you can't
directly refer to identifiers defined inside a generic---that much
should be well known.

Well, generic child packages really are just about the same as nested
generic packages.  Personally, I find it helpful to think of child
units (non-generic ones as well as generic ones) as being located
inside their parents, even though they're textually not located inside
anything.


> Well, you mean that dreadful:
>
> with A.B;
> generic
>     with package A_Inst is new A (<>);
>     with package A_B_Inst is new A_Inst.B (<>);
> package C is
> end C;
>
> This what I am trying to avoid. It is awful (and GNAT has problems with the
> constructs like that).

Yes, that's what I mean.  Sorry.  But it does solve your problem,
doesn't it?  Now you have no problem referring to A_Inst.A1, while the
syntax you seem to prefer (with just one generic formal parameter)
doesn't give you a way to do that.

                                 -- Adam





  parent reply	other threads:[~2007-04-13 15:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-12 20:05 Stupid question Dmitry A. Kazakov
2007-04-12 21:40 ` Adam Beneschan
2007-04-12 22:02   ` Adam Beneschan
2007-04-13  8:20     ` Dmitry A. Kazakov
2007-04-13 13:53       ` Anh Vo
2007-04-13 15:35       ` Adam Beneschan [this message]
2007-04-13 17:12         ` Dmitry A. Kazakov
2007-04-13 18:14           ` Adam Beneschan
2007-04-13 18:50             ` Adam Beneschan
2007-04-13 19:01           ` Randy Brukardt
2007-04-13 19:33             ` Markus E Leypold
2007-04-13 23:39               ` Randy Brukardt
2007-04-14  7:25                 ` Dmitry A. Kazakov
  -- strict thread matches above, loose matches on Subject: below --
2003-10-08  3:12 stupid question Shanon Fernald
2003-10-08  3:31 ` James Rogers
2003-10-08  4:34 ` Steve
2003-10-08 12:54   ` Marin David Condic
2003-10-08 13:01 ` Marin David Condic
2003-10-08 22:18 ` Robert I. Eachus
2003-10-09 10:09   ` Steffen Huber
2003-10-10 16:02     ` Robert I. Eachus
replies disabled

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