comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com
Subject: Exiting from a function or procedure
Date: 2000/04/21
Date: 2000-04-21T00:00:00+00:00	[thread overview]
Message-ID: <rm0M4.39$t25.17152@news.pacbell.net> (raw)
In-Reply-To: sg0q4tb0l6e48@corp.supernews.com

>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.




  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 Exiting from a function or procedure Andres Tarallo
2000-04-21  0:00 ` tmoran [this message]
2000-04-21  0:00   ` Andres Tarallo
2000-04-22  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             ` Robert Dewar
2000-04-24  0:00               ` tmoran
2000-04-24  0:00                 ` Robert Dewar
2000-04-22  0:00       ` Ken Garlington
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