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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.mb-net.net!open-news-network.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Community Input for the Maintenance and Revision of the Ada Programming Language Date: Tue, 12 Sep 2017 18:40:49 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <915874b5-52c0-4aa8-9023-82fddedb816f@googlegroups.com> <67345f73-530c-400b-9eb4-63eeb440154c@googlegroups.com> <9a6338d9-83be-4e45-b8b7-edc56e33537f@googlegroups.com> <2deb28e2-f7e8-4461-b8b8-c2c6cf2784aa@googlegroups.com> <5de470d2-aa3d-4c02-ae2b-266c33a289fe@googlegroups.com> <5126ef7a-3324-4e44-b110-5e4838189f5f@googlegroups.com> <3c76c2ed-319f-410c-8dec-6a80a0948c7a@googlegroups.com> <1c8a3a96-1cdb-4c16-9c25-2da9bbf52cc9@googlegroups.com> NNTP-Posting-Host: MajGvm9MbNtGBKE7r8NgYA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 X-Notice: Filtered by postfilter v. 0.8.2 Content-Language: en-US Xref: news.eternal-september.org comp.lang.ada:48068 Date: 2017-09-12T18:40:49+02:00 List-Id: On 2017-09-12 18:15, Egil H H wrote: > On Tuesday, September 12, 2017 at 5:55:34 PM UTC+2, Dmitry A. Kazakov wrote: >> >> How is that different from: >> >> package Foo is new Ada.Strings.Bounded (1000); >> >> ? > > The difference? > You have one string type that will always allocate 1000 Characters > for every variable of the type, regardless of how many the user specifies as > max. Ada.Strings.Bounded will allocate as many as the user specifies > as max, which is 10 in the part of your example i quoted. So you > would use 9990% more memory... Do you imply that Bounded_String deploys heap? I would consider such implementation a bug. Otherwise you will need two instances and two different types, which is not the intended use. The example only illustrates how discriminants work with assignment and components. > And again, how did you choose 1000? How do you know that will be > enough for all users of your string type? This is why Bounded_String are not used. The problem space almost never provides any upper bound. So the bound is an implementation constraint and thus a premature optimization of worst kind. > Or do you copy/paste the > string type every time you need a new max length? Sure, this what generic packages basically are, dressed up macros. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de