[E-Lang] the return of `return'
Bill Frantz
frantz@pwpconsult.com
Wed, 20 Jun 2001 12:10:02 -0700
At 6:33 AM -0700 6/20/01, Jonathan S. Shapiro wrote:
>There is a consistency of design issue here. Either blocks return the value
>of their last expression/statement or they do not. I strongly advocate that
>they should, because there are various programattic things that are hard to
>do otherwise.
>
>The second question then becomes: what do control structures (if, while,
>for, functions, etc.) return?
>
>For consistency, it is desirable for them to return *something*. If they
>must return something, the logical thing for them to return is the value of
>the last statement executed within the scope that they dominate.
Algol 68 supplied an answer to what control structures return:
if (only) returned the value of the block or EMPTY (of type VOID) when the
block was not executed.
if-else returned the value of the block which was executed.
select/case returned the value of the case block executed. (No, it didn't
have C's error-prone fall-thru case syntax.)
while/for/do returned EMPTY. (Norm Hardy, Charlie Landau, and I thought it
might be interesting to have them return an array of values, one element
for each value produced by the repeated evaluation of the block.)
functions/blocks returned the value of their last statement.
Cheers - Bill
-------------------------------------------------------------------------
Bill Frantz | The principle effect of| Periwinkle -- Consulting
(408)356-8506 | DMCA/SDMI is to prevent| 16345 Englewood Ave.
frantz@pwpconsult.com | fair use. | Los Gatos, CA 95032, USA