[英]Why this erlang function is undefined?
iex(1)> a = :erlang.timestamp
{1458, 585479, 931609}
iex(2)> b = :erlang.timestamp
{1458, 585484, 197713}
iex(3)> :erlang.now_diff(a,b)
** (UndefinedFunctionError) undefined function: :erlang.now_diff/2
:erlang.now_diff({1458, 585479, 931609}, {1458, 585484, 197713})
So I can access erlang functions in elixir, accessing them by :erlang
, but now_diff/2 is undefined. 因此,我可以在elixir中访问erlang函数,通过
:erlang
访问它们,但是now_diff / 2是未定义的。
I have a thought that this timer is not standard erlang module, and needed to be required/imported, but I can't figure out how? 我认为该计时器不是标准的erlang模块,需要/导入,但是我不知道怎么办?
PS Don't advice timex instead if it doesn't have function to calculate timestamps diff with high precision like this erlang function. PS不建议使用timex,如果它没有像erlang函数那样具有高精度计算时间戳diff的功能。 I didn't find reading docs.
我没有找到阅读文档。
Use 采用
:timer.now_diff(a, b)
Functions are not prefixed with :erlang
because they are erlang functions, but because they are part of the erlang
module. 函数没有以
:erlang
为前缀,因为它们是erlang函数,但是因为它们是erlang
模块的一部分。 now_diff is part of the timer module, hence you would use :timer
instead of :erlang
. now_diff是计时器模块的一部分,因此您将使用
:timer
而不是:erlang
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.