From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!rt.uk.eu.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Empty Bounded Containers Date: Fri, 23 May 2014 07:00:06 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="f944b7aa56b4100b8770465c51f11294"; logging-data="23037"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184n68PWxZzalakqnyTlo0B5JhK8W/THPc=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:3A00xX+gscvElJGGiQZJ/h3G1yM= sha1:IH0bBAY6I/A8aj0OhEAYjoPP4B4= Xref: number.nntp.dca.giganews.com comp.lang.ada:186568 Date: 2014-05-23T07:00:06+01:00 List-Id: 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!)