From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Running a preprocessor from GPS? Date: Thu, 30 Jul 2015 14:22:33 +0300 Organization: Tidorum Ltd Message-ID: References: <2df4698f-4c8e-457c-822d-209cb2f8ab5e@googlegroups.com> <014427b1-ff7a-4a69-82e6-0330af77ed96@googlegroups.com> <91f88d79-197c-419f-84a8-908e05967a2c@googlegroups.com> <135c2b00-d13c-4f5d-a586-8aca442d363b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net Uv30jAM9T+ZwfL1AK5EqJArj6/S28NELj7E2s36hCtSvP+V+W8 Cancel-Lock: sha1:BnQcAnw3jpGBK/ckPMbLJ/iuRxQ= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:27195 Date: 2015-07-30T14:22:33+03:00 List-Id: On 15-07-30 11:45 , EGarrulo wrote: > On Thursday, July 30, 2015 at 10:23:23 AM UTC+2, Georg Bauhaus wrote: >> On 30.07.15 10:03, EGarrulo wrote: >>> Not to mention >>> the crippled support for exceptions in Ada. >> >> Do you mean that exceptions of Ada cannot be used for indirecting >> non-local control flow with the help of exception objects? > > Exceptions in Ada cannot carry contextual information, Where > is the usefulness of knowing that something has gone awry, > without any context? For example: "'File not found?' What file > was the program trying to open, and why?" I suspect that you are conflating two possible uses of exception-handling: 1. To let the program detect and possibly recover automatically from run-time failures. 2. To inform the program's user about run-time failures so that the user can understand what went wrong and how to correct it. Ada's exception facility was designed for (1), and is only indirectly useful for (2). The idea is that exceptions should be handled at a level that knows enough about the context to perform the recovery, or to describe the details of the failure to the user. For example, the idiom for opening a file is: File_Name : String := ... begin Open (File, Name => File_Name, ...); -- Successful: do something with the File. exception when ... => -- Here the handler knows which file we tried to open -- and can act accordingly. end; This can be a bit cumbersome in case one needs to open several files in sequence, but then one must also consider if the program should (a) abort on the first missing file, or (b) attempt to open them all, so that it can give the user a complete list of missing files. Associating the name of the missing file with the exception occurrence would help with (a), but not really with the more user-friendly (b). > Exceptions in Ada cannot ... be chained I'm not sure what you mean by "chained", but an Ada exception handler can either raise another exception, or re-raise the same exception, for handling at higher levels. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .