comp.lang.ada
 help / color / mirror / Atom feed
* Raise expressions from AARM.
@ 2024-02-24  9:50 Blady
  2024-02-24 10:39 ` Jeffrey R.Carter
  2024-02-24 10:39 ` Niklas Holsti
  0 siblings, 2 replies; 6+ messages in thread
From: Blady @ 2024-02-24  9:50 UTC (permalink / 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-26 20:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-24  9:50 Raise expressions from AARM Blady
2024-02-24 10:39 ` 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

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