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!.POSTED!not-for-mail From: "Alejandro R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Community Input for the Maintenance and Revision of the Ada Programming Language Date: Thu, 14 Sep 2017 14:30:56 +0200 Organization: A noiseless patient Spider 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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 14 Sep 2017 12:30:57 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="3bfd3ed7f23dcf226e6fc73d6e53ac48"; logging-data="6277"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/H8MzJLp8OjN6osFdsQAoL" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 In-Reply-To: Content-Language: en-US Cancel-Lock: sha1:AYlTE5WjlzORjzpsiWtfJIe51yA= Xref: news.eternal-september.org comp.lang.ada:48129 Date: 2017-09-14T14:30:56+02:00 List-Id: On 13/09/17 18:34, Jeffrey R. Carter wrote: > On 09/13/2017 03:07 PM, Alejandro R. Mosteo wrote: >> On 12/09/17 19:43, Jeffrey R. Carter wrote: >>> On 09/12/2017 04:36 PM, Egil H H wrote: >>>> On Tuesday, September 12, 2017 at 3:43:40 PM UTC+2, Dmitry A. >>>> Kazakov wrote: >>>>> So it can do with the custom type: >>>>> >>>>> with Ada.Text_IO; use Ada.Text_IO; >>>>> procedure Test is >>>>> Max : constant := 1000; >>>>> subtype Max_Length is Natural range 0..Max; >>>>> type Bounded (Size : Max_Length := Max_Length'Last) is record >>>>> Length : Max_Length := 0; >>>>> Text : String (1..Size); >>>>> end record; >>>>> >>>> ... >>>>> Y : Bounded (10); >>>> >>>> Also, allocating 1000 Characters for a string of max length 10 is >>>> hardly an optimal solution... >>> >>> If an actual discriminant is provided, the default is not used. This >>> only allocates 10 characters. >> >> Just going back to my basics, I think it's been years since I used >> default discriminants. In such a case, if I tried to later assign a >> larger instance to this Y, would it work, given that only 10 chars >> were allocated initially? > > No. If you supply a discriminant, the object is constrained to that > subtype. Only is you do not supply a discriminant is the object > unconstrained. Thanks (also for the demo), I suspected as much. Then I guess that an in/out parameter of such a type might be unsafe to assign, in the sense that depending on the actual argument it might succeed or raise.