gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exception handling within a compound statement?


From: Fischlin Andreas
Subject: Re: Exception handling within a compound statement?
Date: Wed, 20 Dec 2023 10:24:22 +0000

Dear Phil,

Modula-2 has the philosophy of handling errors explicitly as the programer strives to write an error free code in the first place. The only exceptions that can be considered are numerical ones, such as an integer or real overflow etc., which are detected and handled by the underlying hardware and system settings. Depending on the current setting for the handling of such exceptions (tolerate or respond etc.) this results typically in a HALT of the Modula-2 program with some information on the causes of the exception and/or triggering of a debugger.

Hope this helps.

Sincerely yours,
Andreas Fischlin


ETH Zurich
Prof. em. Dr. Andreas Fischlin
Systems Ecology - Institute of Biogeochemistry and Pollutant Dynamics
CHN E 24
Universitaetstrasse 16
8092 Zurich
SWITZERLAND

andreas.fischlin@env.ethz.ch

+41 44 633-6090 phone
+41 79 595-4050 mobile

             Make it as simple as possible, but distrust it!
________________________________________________________________________













On 20 Dec 2023, at 04:20, Philip Munts <phil@munts.net> wrote:

Ada allows exception handling within each begin/end block, and
also allows a begin/end block inside a compound statement:

loop
 begin
   raise Program_Error;
 exception
   when Program_Error =>
     ...
 end;
end loop;

Does GM2 allow something similar, or can exceptions be caught
only at the procedure or module level?

I like to use exceptions to propagate errors in Ada embedded
real-time software, since they can be caught and handled
anywhere along the calling chain or just ignored to abort the
program.

If exceptions can only be caught at procedure or module level
on the way out to a program abort, they are much less useful
to me.

Phil


Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]