comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Recursive parameters in generics
Date: Wed, 25 Jul 2007 08:13:02 -0700
Date: 2007-07-25T08:13:02-07:00	[thread overview]
Message-ID: <1185376382.101594.14560@m37g2000prh.googlegroups.com> (raw)
In-Reply-To: <mailman.9.1185345891.3834.comp.lang.ada@ada-france.org>

On Jul 24, 11:43 pm, "Grein, Christoph (Fa. ESG)"
<Christoph.Gr...@eurocopter.com> wrote:
> Adam wrote a fair exegesis:
>
> > The second formal parameter is "with package This_A is new A (S =>
> > S)";  This matches My_A as long as the S parameter of This_A and My_A
> > match... So the question now is whether My_A.S_Of and "whatever"
> > statically denote the same constant, or are static expressions with
> the
> > same value (see 12.7(6)).
> > ...
> > To summarize my conclusions: (1) Your example *should* be legal, ...
>
> I'm not so sure since generic parameters are never static. The actual
> could be an expression like
>
> S => Function_Call & Another_Non_Static;

That's one of the reasons the phrase "when they're referred to outside
the generic" showed up in my previous post.  Inside the generic, I
think the *intent* is that when the generic refers to S, the rules
apply without reference to what the actual for S might be.  But
outside the instance (and, in some cases, inside the visible part of
the instance), the rules apply as if S had been replaced by the
actual, and the properties of the actual can be used.  I think that's
the very general principle involved; I'm not saying that the rules as
written entirely implement this principle.  But here's an example of
what I mean:

   generic
        type T1 is private;
   package Pak1 is
        subtype T2 is T1;

...

   package New_Pak1 is new Pak1 (Integer);

Inside Pak1, you can't refer to T2'Succ, since the generic isn't
"allowed to know" that T2 will be an integer subtype; but outside the
generic, New_Pak1.T2'Succ is certainly legal.  Following the same
general principle, my thought was that if A is instantiated (as My_A)
with S=>"string literal", then while the code inside A would not be
allowed to treat S as static, for code *outside* the generic, My_A.S
(or in this case My_A.S_Of, which renames it) would be considered
static since the actual parameter is a static expression.  However,
I'm not saying that the actual rules about generic objects and static
stuff (4.9) support the general principle in this case.  It may be
that My_A.S_Of is not static and doesn't statically denote anything;
and it may be that the rules are too ambiguous as currently written.
I'm not sure, and I may need to study the RM a bit more closely.

                       -- Adam




      reply	other threads:[~2007-07-25 15:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-23 18:20 Recursive parameters in generics Dmitry A. Kazakov
2007-07-23 19:32 ` Maciej Sobczak
2007-07-23 19:46   ` Dmitry A. Kazakov
2007-07-23 21:51 ` Adam Beneschan
2007-07-24  8:09   ` Dmitry A. Kazakov
2007-07-24 16:00     ` Adam Beneschan
2007-07-25  6:43       ` AW: " Grein, Christoph (Fa. ESG)
2007-07-25 15:13         ` Adam Beneschan [this message]
replies disabled

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