Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!dkuug!freja.diku.dk!skinfaxe.diku.dk!jensting From: jensting@skinfaxe.diku.dk (Jens Tingleff) Newsgroups: comp.lang.modula2 Subject: Re: JPI M2 2.00 - PROCEDURE FUNCTIONS & ERROR CHECKING Message-ID: <1990Jul24.104303.4787@diku.dk> Date: 24 Jul 90 10:43:03 GMT References: <1960.26A95065@puddle.fidonet.org> <90204.213559TRL3@psuvm.psu.edu> <1990Jul24.060519.23417@portia.Stanford.EDU> Sender: news@diku.dk (The Netnews System) Organization: Department Of Computer Science, University Of Copenhagen Lines: 45 dhinds@portia.Stanford.EDU (David Hinds) writes: >In article <90204.213559TRL3@psuvm.psu.edu> TRL3@psuvm.psu.edu (Tim Larson) writes: >>In article <1960.26A95065@puddle.fidonet.org>, [..] >> > I would be very surprised to see a compiler that flagged the above >routine as an error. I don't think that leaving the possibility of [..] Quite right, a warning is perhaps appropriate. >the problem is insurmountable. A compiler could require that all execution >paths end in RETURN statements, but that is still a non-trivial extension >to the language syntax. As well as a VERY pointless one, isn't the general case the Halting Problem ?? Anyway, in a lot of code the programmer *knows* that a RETURN will be encountered. Even if checks are done manually, that may not result in a RETURN, e.g. PROCEDURE FunnyStuff(arg1 : INTEGER) : BOOLEAN; BEGIN IF arg1 < 126 THEN (* Cath errors. *) InOut.WriteString("ERROR : plane just crashed, tough luck. Bye"); InOut.WriteLn; HALT END; CASE arg1 OF (* So this is stupid, so what ? *) 127 : RETURN TRUE | 128 : RETURN FALSE END; END FunnyStuff; Even if M-2 *does* provoke the programmer to reflect on the programming, there is no reason for a straight-jacket requirement of a RETURN statement that's always reached.. . Jens Jens Tingleff MSc EE, Institute of Computer Science, Copenhagen University Snail mail: DIKU Universitetsparken 1 DK2100 KBH O "It never runs around here; it just comes crashing down" apologies to Dire Straits