[erlang-questions] Why doesn't Erlang has return statement?

Richard A. O'Keefe ok@REDACTED
Tue Dec 16 23:53:33 CET 2014


On 16/12/2014, at 9:05 pm, aman mangal <mangalaman93@REDACTED> wrote:
> I have seen similar questions before on the forum but I could never understand the reason behind it. Is it due to theoretical reasons such as return statement makes it hard to reason about the program or practical reasons that it is hard to implement it (this doesn't seem right but I cannot think of anything else)?

What would you use a ‘return statement’ *for*?
You might as well ask why Erlang doesn’t have an ‘assigned GO TO’ statement.

> Moreover, is there a good alternate to avoid nested case statements?

Why avoid them?  Give a *real* example where nested case expressions
(not “statements”, Erlang doesn’t strictly speaking *have* “statements”)
are a problem.

> Making more functions just seems tedious.

That’s not the question, surely?  The question is whether it is *more*
tedious than other alternatives.  And whether it leads to *better* code.

> Using catch statement seems another good alternate but my intuition is that it is not good practice, is it?

‘try . . . catch’ is another ‘case’-like structure; that would be to
cast out devils by means of Beelzebub.

It seems to be a goood rule in all discussions like this to focus on
some actual concrete cases from real code.




More information about the erlang-questions mailing list