comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Discriminant and type extensions
Date: Mon, 5 Oct 2009 15:04:01 -0700 (PDT)
Date: 2009-10-05T15:04:01-07:00	[thread overview]
Message-ID: <42a46538-2430-4738-9cb4-7cbbb0c7db33@b25g2000prb.googlegroups.com> (raw)
In-Reply-To: wccljjp609m.fsf@shell01.TheWorld.com

On Oct 5, 1:42 pm, Robert A Duff <bobd...@shell01.TheWorld.com> wrote:
> "Hibou57 (Yannick Duchêne)" <yannick_duch...@yahoo.fr> writes:
>
>
>
>
>
> > I was looking at two of my generic packages, fully functionals, that
> > is not the trouble, but not expressive enough IMHO.
>
> > The lack, from my point of view, is in the way a type can be extended
> > from a another type with discriminants.
>
> > What I mean : I've got a type in a package, a tagged type with
> > discriminants. Then a second package extends this type, but the
> > discriminants from the extended type does not appears in the extension
> > declaration. When I want to instantiate the type (the extended one), I
> > obviously have to provide the actuals for these discriminants (the
> > ones coming from the type which was extended).
>
> > What do you think about it ?
>
> > Do you think it would be a good proposal to allow the discriminant to
> > be explicitly recalled in an extension declaration ? (just to be more
> > explicit and expressive)
>
> I'm not sure exactly what you mean, but you can do things like this:
>
>     type T (D : Positive) is tagged ...
>     type T2 (D : Positive; D2 : Boolean) is new T(D => D);
>     type T3 is new T(D => 1_000_000);
>     type T4 (D2 : Boolean) is new T(D => 1_000_000);

Well, you can't do any of the last three, since you need an extension
part.  But we'll assume you meant to include one.  :)

I think he wants to try to duplicate the discriminants for
documentation purposes (for clarity), so that

      type T (D : Positive) is tagged ...

      type T2 (D : Positive) is new T with ...  -- [A]

where, I assume, the compiler would check to make sure the
discriminant part of T2 was something-conformant with that of T, and
the declaration would be semantically identical to

      type T2 is new T with ...

It (line [A]) isn't currently legal, but this is:

      type T2 (D : Positive) is new T (D=>D) with ...

However, I'd need to stare at the RM for some time to convince myself
that this is semantically identical in all cases to the simple "type
T2 is new T with...".  (And then I might have to open the RM and read
it after I'm done staring at it.)  Maybe it really is identical, and
all uses of T2 would have identical semantics in all cases.  I'm not
sure.

                             -- Adam



  reply	other threads:[~2009-10-05 22:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-05 17:18 Discriminant and type extensions Hibou57 (Yannick Duchêne)
2009-10-05 20:42 ` Robert A Duff
2009-10-05 22:04   ` Adam Beneschan [this message]
2009-10-05 22:29     ` Yannick Duchêne Hibou57
2009-10-05 22:34       ` Yannick Duchêne Hibou57
2009-10-05 23:08         ` Adam Beneschan
2009-10-07  6:20           ` Yannick Duchêne Hibou57
2009-10-05 22:15   ` Yannick Duchêne Hibou57
2009-10-09  6:29     ` Yannick Duchêne Hibou57
2009-10-09 15:42       ` Jean-Pierre Rosen
2009-10-07  7:21 ` Jean-Pierre Rosen
2009-10-07 15:39   ` Yannick Duchêne Hibou57
replies disabled

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