<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><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 6, 2018 at 10:35 PM, Tristan Sloughter <span dir="ltr"><<a href="mailto:t@crashfast.com" target="_blank">t@crashfast.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div><div>Ooh, that looks similar, but better, to what we did in Erleans:<br></div>
<div><br></div>
<div> erlang:function_exported(<wbr>Module, module_info, 0) orelse code:ensure_loaded(Module),<br></div>
<div> case erlang:function_exported(<wbr>Module, FunctionName, Arity) of<br></div>
<div> true -><br></div>
<div> erlang:apply(Module, FunctionName, Args);<br></div>
<div> false -><br></div>
<div> Default<br></div>
<div> end.<br></div>
<div><br></div>
<div>I guess we should likely switch to `erlang:module_loaded(M)` instead of checking if `module_info` is exported. Thanks!<br></div>
<div><br></div>
<div>Would be nice to have it patched though :)<br></div>
<div><br></div>
<div id="m_-7346980260552055001sig19496053"><div class="m_-7346980260552055001signature">--<br></div>
<div class="m_-7346980260552055001signature"> Tristan Sloughter<br></div>
<div class="m_-7346980260552055001signature"> "I am not a crackpot" - Abe Simpson<br></div>
<div class="m_-7346980260552055001signature"> <a href="mailto:t@crashfast.com" target="_blank">t@crashfast.com</a><br></div>
</div><div><div class="h5">
<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="h5"><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_-7346980260552055001colour" style="color:rgb(136,136,136)"></span></span><br></div>
<div><span><span class="m_-7346980260552055001colour" style="color:rgb(136,136,136)"></span></span><br></div>
<div><span><span class="m_-7346980260552055001colour" style="color:rgb(136,136,136)">Michał.</span></span><br></div>
<div><br></div>
<div><span><span class="m_-7346980260552055001colour" style="color:rgb(136,136,136)"></span></span><br></div>
</div>
</div>
</blockquote></div>
</div>
</div></div><span class=""><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/<wbr>listinfo/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">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>