From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!8nKyDL3nVTTIdBB8axZhRA.user.46.165.242.75.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Empty String confusion; Positive and Natural Date: Tue, 30 Nov 2021 08:29:43 +0000 Organization: Aioe.org NNTP Server Message-ID: References: <053c8a45-2829-4f2e-925c-b72308c1fe61n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: gioia.aioe.org; logging-data="50288"; posting-host="8nKyDL3nVTTIdBB8axZhRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin) Cancel-Lock: sha1:8QGHttNaSFUEBdsRxleMBgoa5/4= X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:63168 List-Id: Kevin Chadwick writes: >> It would clarify your question if you would show the declaration of >> that record type. Does it use the String type, or the >> Unbounded_String type? > > Hopefully I will have a doh moment when I get into the office in the > morning and post code. I am getting a range check exception when I > assign "" to a standard.String in a record by returning the record > from a function. Surely, I must have caused it somehow. If you declare S : String (1 .. 5) and you want to assign a string "foo" to the whole of S you are forbidden to do so by the language: you have to assign 5 characters, no more, no fewer. This can be a royal pain, so we have Ada.Strings.Bounded (if you know the maximum length) or .Unbounded (if you don't, and can afford more overhead), both of which support variable-length strings.