comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: why "unconstrained subtype in component declaration" while said component given default value ?
Date: Sun, 27 May 2018 08:07:03 +0100
Date: 2018-05-27T08:07:03+01:00	[thread overview]
Message-ID: <lyy3g5efvs.fsf@pushface.org> (raw)
In-Reply-To: f9a3c91e-03d0-4053-827b-170ba762dddf@googlegroups.com

Mehdi Saada <00120260a@gmail.com> writes:

> Also, there's something that would be really cool, and I'm curious why
> it could not be allowed: Why can't we provide a private constrained
> subtype, of an inconstrained private type ?
>
> package III is
>    type A (<>) is private;
>    subtype B is A;  -- should be a constrained subtype
> private
>    function Donne_String (N : Positive) return String;
>    type A (N: Positive) is record
>       II : Integer;
>       Chaine : String(1..N) := Give_String(N);
>    end record;
> end III;

The Booch Components originally had the maximum length of a bounded
container fixed at generic instantiation, which is a very limiting
design. So as to avoid forcing all users to rework, I ended up with, for
example,

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);

[...]

   function "=" (Left, Right : in Unconstrained_Collection) return Boolean;

[...]

   procedure Insert (C : in out Unconstrained_Collection; Elem : Item);
   --  Add the item to the front of the collection.

  parent reply	other threads:[~2018-05-27  7:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-26 21:03 why "unconstrained subtype in component declaration" while said component given default value ? Mehdi Saada
2018-05-26 21:40 ` Jere
2018-05-26 22:11   ` Mehdi Saada
2018-05-26 23:55     ` Jere
2018-05-27  0:14       ` Jere
2018-05-27  0:29       ` Mehdi Saada
2018-05-27  0:45         ` Mehdi Saada
2018-05-27 17:15         ` Shark8
2018-05-27 17:30           ` AdaMagica
2018-05-27 18:17             ` Shark8
2018-05-29  1:28               ` AdaMagica
2018-05-29 17:20                 ` Mehdi Saada
2018-05-27  7:45   ` Jeffrey R. Carter
2018-05-26 23:41 ` Shark8
2018-05-27  7:07 ` Simon Wright [this message]
2018-05-27 17:22   ` Shark8
2018-05-27 12:24 ` Mehdi Saada
2018-05-29 22:28   ` Randy Brukardt
replies disabled

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