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 X-Google-Attributes: gid103376,public From: tmoran@bix.com Subject: Exiting from a function or procedure Date: 2000/04/21 Message-ID: #1/1 X-Deja-AN: 614027409 References: X-Complaints-To: abuse@pacbell.net X-Trace: news.pacbell.net 956338711 206.170.24.13 (Fri, 21 Apr 2000 10:38:31 PDT) Organization: SBC Internet Services NNTP-Posting-Date: Fri, 21 Apr 2000 10:38:31 PDT Newsgroups: comp.lang.ada Date: 2000-04-21T00:00:00+00:00 List-Id: >this program i have a procedure that must do something if it's parameters >meet a certain condition; otherwhise it must exit. Do you mean the procedure must exit in the sense of return, or exit in the sense of stopping the program? Your C examples suggests the latter. You could use "pragma import" on the C "exit" procedure and just call it, exactly as your C program does. Your code using an exception is fine except that it catches the exception, prints the error message, and then tries to drop out the bottom of the function without returning any value. You probably want to add a "raise;" statement after the Put, to re-raise the exception. Note also that some compilers are only half-smart and will give a warning on the construct if ... then ... return some_value; else ... raise some_exception; end if; end some_function; because the compiler realizes that if the program takes the "else" branch it will drop out the bottom of the function without returning any value, but the compiler doesn't realize that some_exception will be raised and prevent reaching the bottom of the function.