[E-Lang] the return of `return'
Jonathan S. Shapiro
Wed, 20 Jun 2001 09:33:37 -0400
> Hm.. actually this isn't my style -- I would tend to use `return'
> But I had the impression that other people valued being able to
> return the last expression from a function. If so, I suppose they will
> up now...
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
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.
The explanation of "return" then becomes: "return is guaranteed to be the
last statement executed within enclosing scope <some definition>.
Then it all makes sense semantically, and common "expected" syntactical
conventions (the return statement).