<br>In one respect this is not too bad. We have always viewed throw/catch not as an exception but as a non-local return, so you are not really generating an exception. This is an unfortunate side effect of having a try which catches everything, catch has the same problem. I *know* that you can choose what to catch in try, but it does place it at the same "level" as exceptions.<br>
<br>This is perhaps a suggestion for Erlang3000, try for exits/exceptions and throw/catch as a matching pair where catch only catches throws.<br><br>And one extra suggestion I can't help but make is to use LFE and do:<br>
<br>(cond ((: lists member a caps) (: io format '"Member of capitals\n"))<br> ((: lists member a small) (: io format '"Member of smalls\n"))<br> ((: lists member a nums) (: io format '"Member of nums\n"))<br>
(else (: io format '"Member of capitals\n")))<br><br>:-)<br><br>Robert<br><br><br><div class="gmail_quote">2008/11/20 <span dir="ltr"><<a href="mailto:kdronnqvist@gmail.com">kdronnqvist@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Thanks for your solutions, they give me good insight in how the Erlang world would solve this. I have one more way of solving this that I think is kind of clean and it would be efficient because the lists:member() would need to be evaluated once a match is found.<br>
<br>elseif5(A) -><br> try<br> lists:member(A,?CAPS) andalso throw(caps),<br> lists:member(A,?SMALL) andalso throw(small),<br> lists:member(A,?NUMS) andalso throw(nums),<br> throw(none)<br>
catch<br> throw:caps -> io:format("Member of capital\n");<br> throw:small -> io:format("Member of small\n");<br> throw:nums -> io:format("Member of nums\n");<br>
throw:none -> io:format("Not a member\n");<br> X:Y -> io:format("Bad exception ~p:~p\n",[X,Y])<br> end.<br><br>However, some might think this is the wrong way of handling exceptions. What do you think?<br>
<br>BR,<br>Daniel Rönnqvist<br></blockquote></div><br>