comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Empty Bounded Containers
Date: Fri, 23 May 2014 07:00:06 +0100
Date: 2014-05-23T07:00:06+01:00	[thread overview]
Message-ID: <ly8uptnift.fsf@pushface.org> (raw)
In-Reply-To: cfe5082c-9b50-4c5b-afe1-8dd6ea1640b9@googlegroups.com

sbelmont700@gmail.com writes:

> In the sundry Ada distributions I have around, the "empty" bounded
> containers are fully defined as having a capacity of zero, e.g.
>
> Empty_Vector : constant Vector := (Capacity => 0, others => <>);
>
> which is not intuitively what I would assume.  For instance, the
> following line:
>
> x : BC.Vector (Capacity => 42) := BC.Empty_Vector;
>
> implies an container with a capacity of 42 initialized to a length of
> zero, but it of course throws a constraint error.  In fact, there
> really doesn't seem to be any valid use of the Empty_Vector (et al),
> since the actual capacity is hidden in the private part.  The LRM just
> says it should be the same between the two without addressing the
> discriminant, which isn't much help.
>
> Moreover, the wording seems to legally contradict itself, since by
> stating "If an object of type Vector is not otherwise initialized, it
> is initialized to the same value as Empty_Vector" it would seem to
> imply that
>
> x : BC.Vector (Capacity => 42);
>
> ought to use the values from the Empty_Container, causing the same
> error, leaving no actual way to ever have any bounded containers at
> all.

It is initialized to the same value in the sense that your second 'x'
above "=" BC.Empty_Vector.

(Am I the only one left who thinks of the Ada 95 Booch Components on
seeing 'BC'? some initial confusion here!)


  parent reply	other threads:[~2014-05-23  6:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23  0:20 Empty Bounded Containers sbelmont700
2014-05-23  1:05 ` Adam Beneschan
2014-05-27 14:50   ` Adam Beneschan
2014-05-27 20:59     ` sbelmont700
2014-05-23  6:00 ` Simon Wright [this message]
2014-05-23 15:37   ` Adam Beneschan
2014-05-23 17:54     ` Simon Wright
2014-05-23 21:45 ` 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