function_exported?/ 3在escript中没有按预期工作

Ton*_*Han 0 erlang elixir

我想Code.format_string!/2在我的escript代码中使用Elixir 1.6.为了兼容不同的Elixir版本,我计划function_exported?/3用来查看用户环境中是否支持format_string.但我发现它不能按预期工作.它总是false在Macbook中返回(Elixir是1.6),但它可以正常调用.

我创建了一个演示来描述这个问题:

https://github.com/tony612/escript_export

Jos*_*lim 5

function_exported?/3假设模块已经加载到内存中.你可能想这样做:

if Code.ensure_loaded?(Code) and function_exported?(Code, :format_string!, 2) do
  ...
Run Code Online (Sandbox Code Playgroud)