<div dir="ltr">But the source would be ugly<div><br></div><div>I want to write </div><div><br></div><div> must_read_file(F)</div><div class="gmail_extra"><br></div><div class="gmail_extra">and not</div><div class="gmail_extra"><br></div><div class="gmail_extra"> must(file,read_file,[F])</div><div class="gmail_extra"><br></div><div class="gmail_extra">/Joe</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 27, 2017 at 11:39 AM, Roman Galeev <span dir="ltr"><<a href="mailto:jamhedd@gmail.com" target="_blank">jamhedd@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Imo you can do it with:<div><div>must(M,F,A) -></div><div><span style="white-space:pre-wrap"> </span>case erlang:apply(M,F,A) of</div><div><span style="white-space:pre-wrap"> </span>{ok, Res} -> Res;</div><div><span style="white-space:pre-wrap"> </span>_Err -></div><div><span style="white-space:pre-wrap"> </span>io:format("Error ~p:~p(~p) ~p",[M, F, A, _Err]),</div><div><span style="white-space:pre-wrap"> </span>exit({must, F, A,})</div><div><span style="white-space:pre-wrap"> </span>end.</div></div><div><br></div><div>In this case, you don't need to make new functions out of existing ones, and still get a nice error message.</div><img src="https://mltrk.io/pixel/2GeKwr4RZTWXCSaqKxL8?rid=2GeKwr4RZTWXCSaqKxL8" width="1" height="1" border="0"></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Wed, Sep 27, 2017 at 11:30 AM, Karlo Kuna <span dir="ltr"><<a href="mailto:kuna.prime@gmail.com" target="_blank">kuna.prime@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">could we have something in type specifications that indicates throw case:<br><br>-spec f_name( Args ) -> .....; throw(TE | TE1 | ....).</div><div class="m_-5359999358878083378HOEnZb"><div class="m_-5359999358878083378h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 27, 2017 at 11:25 AM, Attila Rajmund Nohl <span dir="ltr"><<a href="mailto:attila.r.nohl@gmail.com" target="_blank">attila.r.nohl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">2017-09-27 11:08 GMT+02:00 Joe Armstrong <<a href="mailto:erlang@gmail.com" target="_blank">erlang@gmail.com</a>>:<br>
[...]<br>
<span>> This turns out to be very convenient - I read many files<br>
> in my programs, so it's nice to know that must_read_file<br>
> will print a nice error message and terminate<br>
> if I give it a bad filename.<br>
><br>
> Note: I can get the program to crash by writing<br>
><br>
> {ok, B} = file:read_file(F)<br>
><br>
> But I don't get a nice error message telling me the filename.<br>
><br>
> Any takers?<br>
<br>
</span>My problem with all kinds of very common prefixes is that it breaks<br>
function name autocompletion. Or at least makes it harder to use when<br>
I have dozens/hundreds/thousands of function names starting with the<br>
same 3-5 characters - either I have to type those 3-5 characters all<br>
the time plus any more characters to find unique prefix for<br>
autocompletion or have to autocomplete twice (one for the may/must<br>
difference, one for the actual function name). Eclipse (for Java)<br>
helpfully shows the method signature including return value and thrown<br>
exceptions - I think this problem should be solved by the IDEs and not<br>
by naming conventions.<br>
<div class="m_-5359999358878083378m_-988168465365646866HOEnZb"><div class="m_-5359999358878083378m_-988168465365646866h5">______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/list<wbr>info/erlang-questions</a><br>
</div></div></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/list<wbr>info/erlang-questions</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_-5359999358878083378gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">With best regards,<div> Roman Galeev,</div><div> <a href="tel:+420%20702%20817%20968" value="+420702817968" target="_blank">+420 702 817 968</a></div></div></div>
</font></span></div>
<br>______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div></div>