[erlang-questions] module reloading

Alex Alvarez alex@REDACTED
Thu Apr 19 04:55:27 CEST 2018


That's awesome!  Thanks; I'll try the patch out!
Cheers,Alex

On 4/18/2018 at 2:28 AM, "Per Hedeland"  wrote:On 2018-04-18 08:05,
Per Hedeland wrote:
> On 2018-04-18 03:27, Fernando Benavides wrote:
>>
>> Also... Just trying to evaluate _any_ function, loads the module.
That's why instead of loading modules manually, when in the shell, I
tend to write the module name and :, press tab, if nothing pops 
>> up, I type x(). and press enter.
> 
> I tend to do the same, even down to the "arbitrary function name",
but
> it *is* rather quirky, and there is a hint for an obvious and
probably
> straightforward-to-implement (I haven't looked at the relevant code)
> enhancement in your description: why not have the sequence :
> do a code:ensure_loaded() before it (tries to) look up the
> function list?

OK, so I looked at the code, and the change (see below) is so trivial
that there is probably a good reason it doesn't already do that - I
don't know what that reason might be though...

--Per

diff --git a/lib/stdlib/src/edlin_expand.erl
b/lib/stdlib/src/edlin_expand.erl
index bdcefda..4b3e0cc 100644
--- a/lib/stdlib/src/edlin_expand.erl
+++ b/lib/stdlib/src/edlin_expand.erl
@@ -49,8 +49,8 @@ expand_module_name(Prefix) ->
  expand_function_name(ModStr, FuncPrefix) ->
      case to_atom(ModStr) of
   {ok, Mod} ->
-     case erlang:module_loaded(Mod) of
- true ->
+     case code:ensure_loaded(Mod) of
+ {module, Mod} ->
       L = Mod:module_info(),
       case lists:keyfind(exports, 1, L) of
   {_, Exports} ->
@@ -58,7 +58,7 @@ expand_function_name(ModStr, FuncPrefix) ->
   _ ->
       {no, [], []}
       end;
- false ->
+ {error, _What} ->
       {no, [], []}
       end;
   error ->
_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED
http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180418/0efce838/attachment.htm>


More information about the erlang-questions mailing list