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: Bob Duff Newsgroups: comp.lang.ada Subject: Re: Bounded String question Date: Tue, 10 Nov 2015 19:48:40 -0500 Organization: A noiseless patient Spider Message-ID: <87io597447.fsf@theworld.com> References: <7ba56b33-28d4-42d2-8b9b-5ad9f5beab8b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="85c8eae3192bf7c5ee4d997f4c74fbcd"; logging-data="19519"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Y0Uz3D8yIwBxS/E4M6vJa" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:9twarN4KuO3AQha0n0eX3GEfUPc= sha1:lvvvke3TEaSQOKoJxYmhaNbX3t0= Xref: news.eternal-september.org comp.lang.ada:28291 Date: 2015-11-10T19:48:40-05:00 List-Id: Serge Robyns writes: > No_Client_Name : constant T_Client_Name; How about: function No_Client_Name return T_Client_Name is (T_Client_Name (P_Strings.Null_Bounded_String)); ? But why do you need Preelaborate? It's not all that much use if you use GNAT's static elaboration model. > Maybe I'm using bounded strings completely wrong. Well, I think the Ada.Strings.Bounded package is way overengineered. So "using Ada.Strings.Bounded" = "using bounded strings wrong". ;-) 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; along with a few trivial operations. - Bob