Author: Didier Kryn Date: To: dng Subject: Re: [DNG] C exception handling
Le 03/11/2024 à 02:09, Steve Litt a écrit : > Perhaps another way would be to use assert (C) or pragma assert (Ada,
> and be sure to pragma assertions(Assert => Check)) for the time being,
> and as runtime errors are discovered, substitute real error handling.
Assert is most often used to check that a variable is in the proper
range. In Ada you can get this automatic and invisible in the subprogram
body, just by declaring properly the range of the variable. At every
place the variable is assigned a value, Ada asserts that it is in the
range, at compile time whenever possible, otherwise at runtime. If the
value is not in the range it raises the exception Constraint_Error.