<div dir="ltr">Using code:is_loaded/1 has the same roundtrip overhead as code:ensure_loaded(), so in that case you can just use the latter directly without any extra check.<div><br></div><div>But as I see it, the warning should just be seen as a pointer for average users to primarily use the code module, and not as a warning about this function possibly going away or being bad for you, as long as you know what you are using it for.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><br> /Richard</div></div>
<br><div class="gmail_quote">2018-03-07 8:24 GMT+01:00 Michael Truog <span dir="ltr"><<a href="mailto:mjtruog@gmail.com" target="_blank">mjtruog@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"><span class="">
<div class="m_-7436874537547592371moz-cite-prefix">On 03/06/2018 10:54 PM, Metin Akat
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Thanks all. I went with the solution Richard
proposed. And after testing of the full implementation, this
check is certainly not the bottleneck of the system, as Jesper
suggested.</div>
</blockquote>
<br></span>
The only problem with that, is that the documentation specifies that
erlang:module_loaded/1 is only really meant to be used by the code
server (at <a class="m_-7436874537547592371moz-txt-link-freetext" href="http://erlang.org/doc/man/erlang.html#module_loaded-1" target="_blank">http://erlang.org/doc/man/<wbr>erlang.html#module_loaded-1</a>).
If that bothers you, you should use the function code:is_loaded/1
instead.<div><div class="h5"><br>
<br>
<br>
<blockquote type="cite">
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div>
<div class="m_-7436874537547592371h5">
<div><br>
</div>
<div><br>
</div>
<div>On Tue, Mar 6, 2018, at 12:23 PM, Richard
Carlsson wrote:<br>
</div>
</div>
</div>
<blockquote type="cite">
<div>
<div class="m_-7436874537547592371h5">
<div dir="ltr">I was actually considering submitting
such a patch a while back, but one argument
against making that short-cut could be that
operations against the code server should be
serialized. On the other hand I haven't yet come
up with an example where the short-cut would make
a difference that couldn't already happen due to
processor scheduling.<br>
</div>
<div>
<div><br>
</div>
<div>
<div>
<div><br>
</div>
<div> /Richard<br>
</div>
</div>
</div>
<div><br>
</div>
<div>
<div>2018-03-06 16:40 GMT+01:00 Michał Muskała <span dir="ltr"><<a href="mailto:michal@muskala.eu" target="_blank">michal@muskala.eu</a>></span>:<br>
</div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-color:rgb(204,204,204);border-left-style:solid;border-left-width:1px;padding-left:1ex">
<div>
<div><span></span><br>
</div>
<div name="messageBodySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif"><span>On
6 Mar 2018, 16:36 +0100, Richard
Carlsson <<a href="mailto:carlsson.richard@gmail.com" target="_blank">carlsson.richard@gmail.com</a>>,
wrote:</span><br>
</div>
<div><span></span><br>
</div>
<div name="messageReplySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif">
<div><span><br>
</span></div>
<blockquote type="cite" style="margin-top:5px;margin-right:5px;margin-bottom:5px;margin-left:5px;padding-left:10px;border-left-color:rgb(26,188,156);border-left-style:solid;border-left-width:thin">
<div dir="ltr">
<div><span></span><br>
</div>
<div>
<div><span>is_exported(M, F, A)
-></span><br>
</div>
<div><span> case
erlang:module_loaded(M) of</span><br>
</div>
<div><span> false ->
code:ensure_loaded(M);</span><br>
</div>
<div><span> true -> ok</span><br>
</div>
<div><span> end,</span><br>
</div>
<div><span>
erlang:function_exported(M, F,
A).</span><br>
</div>
<div><span></span><br>
</div>
<div><span>(code:ensure_loaded() is
slow compared to the fast call
to erlang:module_loaded(), even
if the module is already in
memory).</span><br>
</div>
<div> <br>
</div>
</div>
</div>
</blockquote>
<div><span><br>
</span></div>
<div>I was recently wondering about this.
Is there a reason code:ensure_loaded()
does not short circuit using
erlang:module_loaded()? It could
probably even skip the request to the
code server entirely in case the module
is already loaded.<br>
</div>
<div><span><span class="m_-7436874537547592371m_-7346980260552055001colour" style="color:rgb(136,136,136)"></span></span><br>
</div>
<div><span><span class="m_-7436874537547592371m_-7346980260552055001colour" style="color:rgb(136,136,136)"></span></span><br>
</div>
<div><span><span class="m_-7436874537547592371m_-7346980260552055001colour" style="color:rgb(136,136,136)">Michał.</span></span><br>
</div>
<div><br>
</div>
<div><span><span class="m_-7436874537547592371m_-7346980260552055001colour" style="color:rgb(136,136,136)"></span></span><br>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
<span>
<div><u>______________________________<wbr>_________________</u><br>
</div>
<div>erlang-questions mailing list<br>
</div>
<div><a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
</div>
<div><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/list<wbr>info/erlang-questions</a><br>
</div>
</span></blockquote>
<div><br>
</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>
</div>
<br>
<fieldset class="m_-7436874537547592371mimeAttachmentHeader"></fieldset>
<br>
<pre>______________________________<wbr>_________________
erlang-questions mailing list
<a class="m_-7436874537547592371moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a>
<a class="m_-7436874537547592371moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a>
</pre>
</blockquote>
<p><br>
</p>
</div></div></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>