<div dir="ltr"><div dir="ltr">On Mon, Oct 24, 2022 at 2:03 AM <<a href="mailto:thutt@harp-project.com">thutt@harp-project.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The original ETHZ compiler didn't check if you included a return<br>
statement. It actually did something that I find to be really nice --<br>
something that would be handy for others to adopt:<br>
<br>
If you did not have a return statement that was executed in a<br>
procedure returning a value, a trap was raised.<br><br></blockquote><div> </div><div>Better than nothing I suppose, but it is always preferable, if possible, for errors to be detected at compile-time rather than runtime.</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"><br>
I am not a fan of the single return, though it would probably be<br>
beneficial for the GSA IR and code generation. The return causes an<br>
immediate return from the function, but the assignment to the<br>
procedure name means that the control flow will continue through the<br>
function. For many non-trivial functions, with a naive compiler,<br>
this will lead to unnecessary code being executed, and perhaps faults<br>
being raised.<br>
<br>
Consider:<br>
<br>
PROCEDURE ListLength(ptr : List) : INTEGER<br>
VAR r : INTEGER;<br>
BEGIN<br>
IF ptr = NIL THEN<br>
RETURN 0;<br>
END;<br>
r := 0<br>
WHILE ptr # NIL DO<br>
INC(r);<br>
ptr := ptr.next;<br>
END<br>
ListLength := r;<br>
RETURN ListLength;<br>
END ListLength; </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I'm not that familiar with Oberon-07, so maybe there's some nuance I'm missing?<br></blockquote><div> </div><div>In Oberon-07 this would simply be:<br></div><div><br></div><div><font face="monospace"> PROCEDURE ListLength(ptr : List) : INTEGER;<br> VAR r: INTEGER;<br> BEGIN<br> r := 0;<br> WHILE ptr # NIL DO<br> INC(r);<br> ptr := ptr.next;<br> END<br> RETURN r<br> END ListLength;</font><br></div><div><font face="monospace"><br></font></div><div><font face="arial, sans-serif">Regards,</font></div><div><font face="arial, sans-serif">Chris Burrows</font></div><div><font face="arial, sans-serif">CFB Software</font></div><div><font face="arial, sans-serif"><a href="https://www.astrobe.com">https://www.astrobe.com</a></font></div><div><font face="monospace"><br></font></div><div> </div></div></div>