From mboxrd@z Thu Jan 1 00:00:00 1970
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Blady
Newsgroups: comp.lang.ada
Subject: Raise expressions from AARM.
Date: Sat, 24 Feb 2024 10:50:31 +0100
Organization: A noiseless patient Spider
Message-ID:
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 24 Feb 2024 09:50:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0797415f6828158c9da18fbcfb46b142";
logging-data="1199368"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Qm9e/BlxJUzA7plpWLiCA"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:vIBHheHg6OUcjVI/EDtZK8scNoo=
Content-Language: fr, en-US
Xref: news.eternal-september.org comp.lang.ada:66119
List-Id:
Hello,
AARM Ada 2022 section 11.3 presents some uses of raise expressions
including this one:
(http://www.ada-auth.org/standards/22aarm/html/AA-11-3.html)
2.a.10/4 ...
B : Some_Array := (1, 2, 3, others => raise
Not_Valid_Error);
What could be the use cases?
My guess: whatever the size of Some_Array (greater than 3), B is
elaborated but raises Not_Valid_Error when accessing component beyond
position 3:
type Some_Array is array (Positive range 1..10) of Natural;
...
B : Some_Array := (1, 2, 3, others => raise Not_Valid_Error);
...
begin
X := B (2); -- OK
X := B (6); -- raises Not_Valid_Error
end;
Is it correct?
NB: GNAT 13.2 issues a compilation error:
>>> error: "others" choice not allowed here
see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113862
Thanks, Pascal.