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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d8a4797a79f9c90f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-27 11:11:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!skynet.be!skynet.be!louie!tlk!not-for-mail Sender: lbrenta@lbrenta.corp.emc.com Newsgroups: comp.lang.ada Subject: Re: I/O - exception handling References: From: Ludovic Brenta Date: 27 May 2003 20:11:05 +0200 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 213.190.149.159 X-Trace: 1054059063 reader0.news.skynet.be 11132 fa058819/213.190.149.159:59834 X-Complaints-To: abuse@skynet.be Xref: archiver1.google.com comp.lang.ada:37848 Date: 2003-05-27T20:11:05+02:00 List-Id: Dmitriy Anisimkov writes: > declare > Resource : Resource_Type; > begin > Open (Resource); > Use_This (Resource); > exception > when Constraint_Error => Do_Something; > final > if Is_Open (Resource) then > Close (Resource); > end if; > end; > > Is bad or not safe ? > > Where block from "final" to "end" would be executed in both cases, > normal and any-exceptional. How different is this from: declare Resource : Resource_Type; begin begin Open (Resource); Use_This (Resource); exception when Constraint_Error =Do_Something; end; if Is_Open (Resource) then Close (Resource); end if; end; I think that this is the C++ idiom, too. -- Ludovic Brenta.