🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #964

Re: JPI M2 2.00 - PROCEDURE FUNCTIONS & ERROR CHECKING

#964
From: Preston Briggs
Date: Tue, 24 Jul 1990 16:23
29 lines
1637 bytes
In article <1990Jul24.060519.23417@portia.Stanford.EDU> dhinds@portia.Stanford.EDU (David Hinds) writes:

>>PROCEDURE IllBehavedFunc(IWantToBehave: BOOLEAN): BOOLEAN;
>>BEGIN
>>IF IWantToBehave THEN
>>RETURN TRUE
>>END
>>END IllBehavedFunc;

>    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
>reaching the end of a procedure without a RETURN statement violates the
>syntax of M2 - am I wrong?  If I'm right, then there is no way for the
>compiler, in the general case, to determine if the illegal exit might
>ever be executed.

You're correct that it isn't specified in the syntax.
I think it probably can't be.  However, the compiler
can still detect that there exists a path from the entrance
to the END of a function with no RETURN.  It's one of the
advantages of using control constructs with the infamous
"single-entrance, single-exit" property.

If people are curious, I can show how it works;
but it'll be a somewhat involved posting.

-- 
Preston Briggs				looking for the great leap forward
preston@titan.rice.edu
Technical Details
Message-ID: <10180@brazos.Rice.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!erato.rice.edu
References: <1960.26A95065@puddle.fidonet.org> <90204.213559TRL3@psuvm.psu.edu> <1990Jul24.060519.23417@portia.Stanford.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!erato.rice.edu
From: preston@erato.rice.edu (Preston Briggs)
Newsgroups: comp.lang.modula2
Subject: Re: JPI M2 2.00 - PROCEDURE FUNCTIONS & ERROR CHECKING
Message-ID: <10180@brazos.Rice.edu>
Date: 24 Jul 90 16:23:29 GMT
References: <1960.26A95065@puddle.fidonet.org> <90204.213559TRL3@psuvm.psu.edu> <1990Jul24.060519.23417@portia.Stanford.EDU>
Sender: root@rice.edu
Organization: Rice University, Houston
Lines: 29