[E-Lang] the return of `return'
Jonathan S. Shapiro
shap@eros-os.org
Mon, 18 Jun 2001 08:09:23 -0400
Based on Darius Bacon's comments, I am wondering if I should have actually
*read* the new syntax thread.
If a "return" statement is included in the language, and the function
returns a value, the return value should be *required* at the site of the
"return" statement. There should be no other means for specifying a return
value from a function.
The reason for this is that the notion of specifying function return values
this way is too deeply wired into too many languages, and a "reveal"
primitive adds insufficient value to justify the confusion it engenders.
Those programmers who are bright enough to use the reveal statement
correctly are bright enough to create local variables and use them with the
return statement. Conversely, those programmers who are *not* bright enough
to use reveal correctly are likewise not bright enough to *maintain* code
that uses reveal.
Stick to traditional return.
Make the value of a block be the value returned by the last statement in the
block -- this was an error in the C design.
However, make the use of "return" as the termination of a function be
mandatory. That is, a function should not by default return the value of its
last enclosing block.
I fully understand that my last item is unnecessary if blocks return values.
However, there is a class of errors that it helps to avoid, and it is one of
those cases where the rule can be relaxed later at no cost, but not imposed
later without a break in compatibility.
Jonathan