comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Q: Trouble creating array and discriminated type
Date: Mon, 23 Jan 2017 08:19:21 +0000
Date: 2017-01-23T08:19:21+00:00	[thread overview]
Message-ID: <lyy3y2i3xy.fsf@pushface.org> (raw)
In-Reply-To: o64d7r$b6d$1@dont-email.me

"G.B." <bauhaus@notmyhomepage.invalid> writes:

> Defaults for discriminants of tagged types would not be permitted,
> only if objects of the type can not have their discriminants changed
> after creation (tagged limited). The reason is stated in AARM 3.7(9.*)
> and it seems to say "It's complicated".
>
> The paragraph suggest that for some use cases, one can declare a
> subtype that sets the discriminants to default values. IIUC, these
> subtypes can then be used in derivations also.

Not sure about use in derivations, but I have

   generic
      Maximum_Size : Positive;
   package BC.Containers.Collections.Bounded is

      type Unconstrained_Collection
        (Maximum_Size : Positive) is new Abstract_Collection with private;

      subtype Collection
         is Unconstrained_Collection (Maximum_Size => Maximum_Size);

I've never been happy about Maximum_Size there, but that's the sort of
thing that happens when you already have a published interface that
you're reluctant to change!

  reply	other threads:[~2017-01-23  8:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 22:55 Q: Trouble creating array and discriminated type b.mcguinness747
2017-01-20 23:48 ` gautier_niouzes
2017-01-21  7:23 ` Simon Wright
2017-01-21  9:41 ` Jeffrey R. Carter
2017-01-21 17:05 ` Stephen Leake
2017-01-22  5:12   ` Robert Eachus
2017-01-23  8:02   ` G.B.
2017-01-23  8:19     ` Simon Wright [this message]
2017-01-21 18:55 ` b.mcguinness747
replies disabled

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