From: Ray Blaak <blaak@infomatch.com>
Subject: Re: Exiting from a function or procedure
Date: 2000/04/22
Date: 2000-04-22T00:00:00+00:00 [thread overview]
Message-ID: <m3k8hqorqr.fsf@ns55.infomatch.bc.ca> (raw)
In-Reply-To: BKmM4.214$nb6.208368@news.pacbell.net
tmoran@bix.com writes:
> > So NEVER EVER ignore warnings, consider them as errors. In
> > fact you might want to use -gnatwe so the compiler will
> > treat them as errors enforcing this discipline.
>
> This is not always a good idea. For instance
> if OK then
> return some_value;
> else
> Log_And_Raise_Error;
> end if;
> end some_function;
> is a perfectly legitimate paradigm in Ada that would become
> illegal in Gnat with -gnatwe, since the compiler doesn't know
> that Log_And_Raise_Error will never return.
I always put in a dummy return in these cases, just to avoid such warnings, and
for safety if the log routine ever *doesn't* raise an exception (e.g. maybe due
to some maintenance change in the future).
Of course, I also prefer a single return point, so I would have written:
result := default_value;
if OK then
result := ok_value;
else
Log_And_Raise_Error;
end if;
return result;
end some_function;
--
Cheers, The Rhythm is around me,
The Rhythm has control.
Ray Blaak The Rhythm is inside me,
blaak@infomatch.com The Rhythm has my soul.
next prev parent reply other threads:[~2000-04-22 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 ` Ken Garlington
2000-04-22 0:00 ` tmoran
2000-04-22 0:00 ` Ray Blaak [this message]
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
2000-04-22 0:00 ` Pablo Moisset
2000-04-23 0:00 ` Robert Dewar
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