🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.ada
Article #1015

Re: Exception handling question

#1015
From: Jan Kok
Date: Mon, 13 Oct 1986 11:21
56 lines
2816 bytes
In article <2737@burdvax.UUCP> eric@burdvax.UUCP (Eric Marshall) writes:
>                . . .                    The LRM paragraph says
>
>	the raise statement with no exception name is only allowed in
>	an exception handler, but not in the sequence of statements of
>	a subprogram, ... enclosed by the handler.
>
>All of these additional constructs can only be introduced by
>a block statement. The paragraph never explicitly addresses the
>raising of the exception in the statements of the block, therefore
>it seems the posted program is indeed illegal.

I disagree: I think the original program is correct Ada (provided
that Textio is replaced by Text_Io of course). A raise statement
without an exception name is allowed, it is not a subprogram, package,
task or generic unit, to which the forbidding rule quoted applies.

To return to the posted program: it is not clear to me (but I may be
oversuspicious) whether the systems which cause printing "Missed it"
missed the first or the second exception handler, and I suggest to
insert an extra Put_Line to ascertain this. So my proposed
modification is:

with Text_Io; -- was Textio in original

procedure Foo is
   Bar : exception;
begin
    begin
        begin
            raise Bar;
        exception                     -- Handler 1
            when Bar =>
                begin
                    Text_Io.Put_Line("Handler 1 got it");
                    raise;
                exception             -- Handler 2
                    when Bar =>
                        Text_Io.Put_Line("Handler 2 got it");
                end;
        end;
    exception                         -- Handler 3
        when Bar =>
            Text_Io.Put_Line("Some handler missed it");
    end;
end Foo;
-- 

Russell did not write that changing "raise;" into "raise Bar;"
corrected the performance for the failing compiler (did he?).
-- 
Mail: Jan Kok, CWI (afd. NW), Postbus 4079, NL-1009 AB Amsterdam, Nederland
UUCP: jankok@mcvax.uucp
---------------------------------------------------------------
   One of the Warner Bros to Albert Einstein:
      I have a theory about relatives myself : Don't hire them!
Technical Details
Message-ID: <313@zuring.mcvax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!think!husc6!seismo!mcvax!jankok
References: <2729@burdvax.UUCP> <8610072133.AA10009@ucbvax.Berkeley.EDU> <2737@burdvax.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!think!husc6!seismo!mcvax!jankok
From: jankok@mcvax.uucp (Jan Kok)
Newsgroups: net.lang.ada
Subject: Re: Exception handling question
Message-ID: <313@zuring.mcvax.UUCP>
Date: Mon, 13-Oct-86 07:21:39 EDT
Article-I.D.: zuring.313
Posted: Mon Oct 13 07:21:39 1986
Date-Received: Tue, 14-Oct-86 07:31:36 EDT
References: <2729@burdvax.UUCP> <8610072133.AA10009@ucbvax.Berkeley.EDU> <2737@burdvax.UUCP>
Reply-To: jankok@zuring.uucp (Jan Kok)
Organization: CWI, Amsterdam
Lines: 56
Apparently-To: rnews@mcvax