Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!snorkelwacker!mit-eddie!uw-beaver!uw-june!pattis From: pattis@cs.washington.edu (Richard Pattis) Newsgroups: comp.lang.modula2 Subject: Re: JPI M2 2.00 - PROCEDURE FUNCTIONS & ERROR CHECKING Summary: How another language (Ada) does it Message-ID: <12633@june.cs.washington.edu> Date: 24 Jul 90 19:00:49 GMT References: <2029.26AAA199@puddle.fidonet.org> Organization: U of Washington, Computer Science, Seattle Lines: 19 Just to see how this "problem" is handled elsewhere: Ada must report a static semantic error (excuse me, for those of you reading SIGPLAN) if a function has NO return statement. It does not have to diagnose whether the function must execute a return statement. If the end of a function is reached without executing a return statement, Ada raises one of its standard exceptions (PROGRAM_ERROR). Interestingly enough, that exception can be handled in the function itself, so we can include a safeguard (although such code is rarely, if ever used). FUNCTION F (params) RETURN INTEGER IS locals BEGIN some hairy computation that terminates, but may or may not execute a return statement EXCEPTION WHEN PROGRAM_ERROR => RETURN 0; END F; Rich Pattis