[E-Lang] the return of `return'

Jonathan S. Shapiro shap@eros-os.org
Wed, 20 Jun 2001 09:33:37 -0400


> Hm.. actually this isn't my style -- I would tend to use `return'
consistently.
> But I had the impression that other people valued being able to
automatically
> return the last expression from a function.  If so, I suppose they will
speak
> 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
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.

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).


Jonathan