<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 25, 2022 at 7:03 AM August Karlstrom <<a href="mailto:fusionfile@gmail.com">fusionfile@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Another ugly aspect of return statements is that they potentially make <br>
the code lie. Consider this statement for instance:<br>
<br>
        WHILE i < 100 DO<br>
                ...<br>
        END<br>
<br>
When we see the loop it's natural to conclude that it will go on until i <br>
 >= 100. However, with return statements there is no such guarantee.<br>
<br></blockquote><div><br></div><div>Yes indeed. Another (even worse?) lie is when a RETURN is used here:</div><div><br></div><div><font face="monospace">   FOR i := 0 TO 99 DO</font></div><div><font face="monospace">      ...</font></div><div><font face="monospace">   END</font></div><div><br></div><div>It is natural to conclude that the loop will execute <i>exactly</i> 100 times. However, with return statements there is no such guarantee.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
What I would like to know is why the return statement was introduced in <br>
Modula-2. Was it to compensate for the removal of goto in Pascal?<br><br></blockquote><div>That is the opinion of Richard Gleaves, one of the earliest Modula-2 pioneers. In his book, <i>Modula-2 for Pascal Programmers</i>, he wrote:</div><div><br></div><div>"Pascal's GOTO statement is missing from Modula-2; in its place are the LOOP/EXIT and RETURN statements and the standard procedure HALT. LOOP/EXIT statements are used to express repetitive statement sequences which contain several exit points. RETURN is a limited form of GOTO; it transfers control to the end of the current procedure. HALT terminates the currently running program."</div><div><br></div><div><a href="https://link.springer.com/book/10.1007/978-1-4613-8531-8">https://link.springer.com/book/10.1007/978-1-4613-8531-8</a><br></div><div><br></div><div>In that context they were a step in the right direction.</div><div><br></div><div>Regards,</div><div>Chris Burrows</div><div>CFB Software</div><div><a href="https://www.astrobe.com">https://www.astrobe.com</a></div><div><br></div><div> </div></div></div>