From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=BAYES_00,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Code flow control Date: Fri, 15 Oct 2021 19:48:06 +0200 Organization: Adalog Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 15 Oct 2021 17:48:06 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="2ea89f1e859d82315695367c89e9b825"; logging-data="29199"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/MzKqT0mdU9xtSQZ2hsCj" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Cancel-Lock: sha1:TLlGcsd7pefhKyOvbQ/hTkAqlq8= In-Reply-To: Content-Language: fr Xref: reader02.eternal-september.org comp.lang.ada:63009 List-Id: Le 15/10/2021 à 17:08, Kevin Chadwick a écrit : > Although surprised that pragma No_Exception_Propagation seems to > prevent access to some exception information. I am happy with Adas > exception mechanism. I have read that exceptions should not be used > for code flow. Some people reserve exceptions for signalling errors. I regard them as a way to handle "exceptional" situations, i.e. when the normal flow of control cannot continue. For example, in a deep recursive search, they are handy to stop the recursion and go back to top level when you have found what you were looking for. Some would disagree with that. > For Ada after perusing various threads on this mailing list around > best practice I am considering using exceptions locally but also have > an in out variable for code flow control at the point of use. Is that > the way with the caveat that it all depends on the task at hand? I definitely would prefer an exception, on the ground that you can omit the check, but you cannot ignore an exception. > In Go with vscode a static checker will warn if an error type > variable is returned without a following if error utilisation (check > usually of the form if err /= nil). > > I have read that Spark has some kind of static analysis to achieve > similar as it forbids exceptions. > > It is not the end of the world but is there any static analyser that > could do similar for Ada. IOW save me some time or perhaps worse > whenever I have simply omitted the check by accident, in haste or > distraction. An interesting idea for AdaControl, especially if you have some funding for it ;-) -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52 https://www.adalog.fr