[erlang-questions] Why doesn't Erlang has return statement?
Tue Dec 16 22:12:29 CET 2014
Thank you all for your replies. Now I have more clear understanding of why
Erlang doesn't have *return *statements :)
On Tue Dec 16 2014 at 7:34:49 AM Loïc Hoguin <essen@REDACTED> wrote:
> 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
> that's expensive.
> 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
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
> Loïc Hoguin
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions