<div dir="ltr">When I first started using Erlang I was missing the return statement as well, in other languages return gave me an easy way to exit a function as early as possible, i,e, when this thing is not true then don't continue but exit. This kept the functions pretty clean.<div><br></div><div>Pattern matching has completely replaced this for me.</div><div><br></div><div>-Mark</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 16, 2014 at 11:53 PM, Richard A. O'Keefe <span dir="ltr"><<a href="mailto:ok@cs.otago.ac.nz" target="_blank">ok@cs.otago.ac.nz</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
On 16/12/2014, at 9:05 pm, aman mangal <<a href="mailto:mangalaman93@gmail.com">mangalaman93@gmail.com</a>> wrote:<br>
> 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)?<br>
<br>
</span>What would you use a ‘return statement’ *for*?<br>
You might as well ask why Erlang doesn’t have an ‘assigned GO TO’ statement.<br>
<span class=""><br>
> Moreover, is there a good alternate to avoid nested case statements?<br>
<br>
</span>Why avoid them?  Give a *real* example where nested case expressions<br>
(not “statements”, Erlang doesn’t strictly speaking *have* “statements”)<br>
are a problem.<br>
<span class=""><br>
> Making more functions just seems tedious.<br>
<br>
</span>That’s not the question, surely?  The question is whether it is *more*<br>
tedious than other alternatives.  And whether it leads to *better* code.<br>
<span class=""><br>
> Using catch statement seems another good alternate but my intuition is that it is not good practice, is it?<br>
<br>
</span>‘try . . . catch’ is another ‘case’-like structure; that would be to<br>
cast out devils by means of Beelzebub.<br>
<br>
It seems to be a goood rule in all discussions like this to focus on<br>
some actual concrete cases from real code.<br>
<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Mark Nijhof<br><div><div>t:   <a href="https://twitter.com/MarkNijhof" target="_blank">@MarkNijhof</a><br>s:  marknijhof</div></div><div><br></div></div></div>
</div>