[erlang-questions] Why doesn't Erlang has return statement?
Tue Dec 16 13:34:40 CET 2014
Erlang has no statements, it only has expressions. All expressions
return a value. So there is no need for a "return" instruction, the last
expression executed gives the return value of the function.
If you use function clauses in addition to case expressions, you
shouldn't have too many levels deep. If you do, create a new function.
Avoid using catch for these things because it creates a stacktrace and
On 12/16/2014 10:05 AM, aman mangal wrote:
> Hi everyone,
> 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)?
> Moreover, is there a good alternate to avoid nested case statements?
> Making more functions just seems tedious. Using /catch /statement seems
> another good alternate but my intuition is that it is not good practice,
> is it?
> Thank you
> Aman Mangal
> www.prism.gatech.edu/~amangal7 <http://www.prism.gatech.edu/~amangal7>
> erlang-questions mailing list
More information about the erlang-questions