刚遇到的一个module加载的小问题

最近clone了一个开源项目最新版本,代码启动的时候总是报错,超纠结,以前没这问题啊= =

查看了源码错误是在erlang:function_exported(xx, xx, 0)这个函数位置。代码的执行依赖于这个函数的返回,

API对此函数的说明是:Returns true if the module Module is loaded and contains an exported function Function/Arity; otherwise false.

但明明模块是有这个导出函数的啊,然后我在控制台再次手工调用了一次这个方法,显示结果是true。

第一次调用时返回false,第二次调用时返回true,呃,应该是code load的问题。

查看一下文档http://www.ostools.net/apidocs/apidoc?api=erlang

说的很清楚:In interactive mode, code is dynamically loaded when first referenced. When a call to a function in a module is made, and the module is not loaded, the code server searches the code path and loads the module into the system.

好吧,那我只能手工加载了,在函数调用之前,调用code:ensure_loaded对模块进行主动加载,果然没问题了。

但是,在我重新clone该项目的最新代码时发现,作者在修订版本里又主动把这句话加上了,⊙﹏⊙b汗

 

转载于:https://www.cnblogs.com/star-star/archive/2012/12/25/2832527.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值