comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: Exiting from a function or procedure
Date: 2000/04/24
Date: 2000-04-24T00:00:00+00:00	[thread overview]
Message-ID: <8e059m$3u$1@nnrp1.deja.com> (raw)
In-Reply-To: vzJM4.1253$t25.356170@news.pacbell.net

In article <vzJM4.1253$t25.356170@news.pacbell.net>,
  tmoran@bix.com wrote:
>      if not OK then
>        Log_And_Raise_Error;
>      end if;
>      return some_value;
>    end some_function;

I find the above code a very poor choice, precisely because,
as Tom notes, it will worry a maintenance programmer as to
what is going on! Far better is

      if not OK then
        Log_And_Raise_Error;
        raise Program_Error;
      end if;

or if you want to take the effort

      if not OK then
        Log_And_Raise_Error;
        raise Impossible_Exception_Cannot_Be_Raised;

Still for those using GNAT, use the opportunity to learn about
pragma No_Return, since it is a very clear way of documenting
the special case of a procedure that never returns.

By the way, I think it is a terrible design choice in Ada 95
that Raise_Exception can return to the caller. We end up special
casing this in GNAT to avoid the warning in this case (raising
Program_Error seems reasonable enough if Raise_Exception returns
and the return path is unblocked.


Sent via Deja.com http://www.deja.com/
Before you buy.




  parent reply	other threads:[~2000-04-24  0:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-21  0:00 Exiting from a function or procedure Andres Tarallo
2000-04-21  0:00 ` tmoran
2000-04-21  0:00   ` Andres Tarallo
2000-04-22  0:00     ` Robert Dewar
2000-04-22  0:00       ` Pablo Moisset
2000-04-23  0:00         ` Robert Dewar
2000-04-22  0:00       ` Ken Garlington
2000-04-22  0:00       ` tmoran
2000-04-22  0:00         ` Ray Blaak
2000-04-22  0:00           ` David Starner
2000-04-23  0:00         ` Robert Dewar
2000-04-23  0:00           ` tmoran
2000-04-24  0:00             ` Robert Dewar
2000-04-24  0:00               ` tmoran
2000-04-24  0:00                 ` Robert Dewar
2000-04-24  0:00             ` Robert Dewar [this message]
2000-04-24  0:00       ` Scott Ingram
2000-04-22  0:00   ` Robert Dewar
2000-04-21  0:00 ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox