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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dabd2d2ffbcf1daa,start X-Google-Attributes: gid103376,public From: "Andres Tarallo" Subject: Exiting from a function or procedure Date: 2000/04/21 Message-ID: #1/1 X-Deja-AN: 613970527 Organization: Posted via Supernews, http://www.supernews.com X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: comp.lang.ada X-Complaints-To: newsabuse@supernews.com Date: 2000-04-21T00:00:00+00:00 List-Id: 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)