From: "Andres Tarallo" <atarallo@chasque.apc.org.NOSPAM>
Subject: Exiting from a function or procedure
Date: 2000/04/21
Date: 2000-04-21T00:00:00+00:00 [thread overview]
Message-ID: <sg0q4tb0l6e48@corp.supernews.com> (raw)
I'm currently learning ADA, my compiler is GNAT 3.12 for Windows and
my sources are an old translation of a book from Henry Ledgard (Dated 1983)
and the tutorials and articles I've downloaded from "The Brave ADA
Programmers Site".
I'm currently working in a small program to handle polinomials, in
this program i have a procedure that must do something if it's parameters
meet a certain condition; otherwhise it must exit.
What I want to do expressed i pseudo-C lenguage is something like
this:
int sum(A, B){
if (A == B)
/* Do something usefull with this */
else
exit(0); /* something went wrong */
endif;
}
From my readings i learned that i have to do this via exceptions; the
way
to do this I achieved is:
function "+"(izq, der: in term) return term is
aux: term;
error_suma: exception;
begin
if (izq.exponente = der.exponente) then
aux.coeficiente:= (izq.coeficiente + der.coeficiente);
aux.exponente:= izq.exponente;
return aux;
else
raise error_suma;
end if;
exception
when error_suma => Put(" ERROR !!!");
end;
When I compile this it compiles fine, however i get a warning
telling me that this could raise an exception during runtime.
I'm still not very familiar with exceptions and it's handling,
Am I doing things in the right way? After displaying the message may program
will terminate?
Thanks in advance, apologize me for my grammar and vocabulary;
english is not my mother tongue
Andres Tarallo
(atarallo@chasque.apc.org)
next reply other threads:[~2000-04-21 0:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-04-21 0:00 Andres Tarallo [this message]
2000-04-21 0:00 ` Exiting from a function or procedure 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 ` 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
2000-04-22 0:00 ` Ken Garlington
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