From: Simon Wright <simon@pushface.org>
Subject: Re: Empty String confusion; Positive and Natural
Date: Tue, 30 Nov 2021 08:29:43 +0000 [thread overview]
Message-ID: <lypmqivyfc.fsf@pushface.org> (raw)
In-Reply-To: bea93bf3-f282-4e9b-8806-2b956d58fe51n@googlegroups.com
Kevin Chadwick <kevc3no4@gmail.com> 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.
next prev parent reply other threads:[~2021-11-30 8:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-29 17:34 Empty String confusion; Positive and Natural Kevin Chadwick
2021-11-29 18:05 ` Jeffrey R.Carter
2021-11-29 19:19 ` Niklas Holsti
2021-11-29 22:50 ` Kevin Chadwick
2021-11-30 8:29 ` Simon Wright [this message]
2021-11-30 8:34 ` Niklas Holsti
2021-11-30 10:00 ` Jeffrey R.Carter
2021-11-30 12:17 ` Kevin Chadwick
2021-11-30 12:54 ` J-P. Rosen
2021-11-30 13:12 ` Kevin Chadwick
2021-11-30 7:40 ` ldries46
2021-11-30 8:21 ` Simon Wright
2021-11-30 12:39 ` ldries46
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox