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!mx02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Bounded String question Date: Tue, 10 Nov 2015 19:01:38 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <7ba56b33-28d4-42d2-8b9b-5ad9f5beab8b@googlegroups.com> <87io597447.fsf@theworld.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Wed, 11 Nov 2015 01:59:24 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="caa759af2a9c666aec02942f6fe5abd6"; logging-data="30095"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18aYwvLE8yMfwQfoztr2CLZRM82CkhdgoM=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: <87io597447.fsf@theworld.com> Cancel-Lock: sha1:9RHHa+qIg4UnM/MSbKPqcfUQojU= Xref: news.eternal-september.org comp.lang.ada:28292 Date: 2015-11-10T19:01:38-07:00 List-Id: On 11/10/2015 05:48 PM, Bob Duff wrote: > > I suggest rolling your own. No need for generics. > > type Bounded_String (Max_Length : Natural := ...) is limited record > Length : Natural := 0; > Chars : String (1 .. Max_Length); > end record; Except that using Natural for Max_Length results in GNAT allocating Integer'Last characters for Chars, which is unlikely to fit on the stack. -- Jeff Carter "I'll get broads up here like you wouldn't believe. Swingers. Freaks. Nymphomaniacs. Dental hygienists." Play It Again, Sam 125