comp.lang.ada
 help / color / mirror / Atom feed
From: Blady <p.p11@orange.fr>
Subject: Raise expressions from AARM.
Date: Sat, 24 Feb 2024 10:50:31 +0100	[thread overview]
Message-ID: <urce58$14j88$1@dont-email.me> (raw)

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.

             reply	other threads:[~2024-02-24  9:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-24  9:50 Blady [this message]
2024-02-24 10:39 ` Raise expressions from AARM Jeffrey R.Carter
2024-02-25 11:09   ` Blady
2024-02-24 10:39 ` Niklas Holsti
2024-02-25 11:23   ` Blady
2024-02-26 20:01     ` Niklas Holsti
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox