- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 ExProf 中,Elixir 函数名称在编译后被打印出来,我认为是它们的 Erlang 名称。一个例子是
Enum.reduce/3
'Elixir.Enum':'-reduce/3-lists^foldl/2-0-'/3
-lists^foldl/2-0-
在哪里部分来自?为什么会有多个
/3
?为什么有些名字
-
前缀?
^
是什么意思意思是?为什么
2-0-
?
最佳答案
How do I parse this string?
'Elixir.Enum':'-reduce/3-lists^foldl/2-0-'/3
是 Erlang 中的函数引用语法,引用了一个名为
-reduce/3-lists^foldl/2-0-
的函数在模块
Elixir.Enum
, 数量为 3,类似于
&Enum."-reduce/3-lists^foldl/2-0-"/3
在 Elixir 中。
Where does the
-lists^foldl/2-0-
part come from?
-$fn/$arity-$something-$count-
是 Erlang 在堆栈跟踪(显然是分析输出)中为
$fn/$arity
中定义的匿名函数返回的名称.通常,您会看到类似
-main/0-fun-0-
的内容。 ,即
$something == "fun"
,例如,这个:
defmodule Foo do
def main do
try do
(fn -> raise("foo") end).()
rescue
_ -> IO.inspect System.stacktrace
end
end
end
[{Foo, :"-main/0-fun-0-", 0, [file: 'foo.ex', line: 4]},
{Foo, :main, 0, [file: 'foo.ex', line: 4]},
{:erl_eval, :do_apply, 6, [file: 'erl_eval.erl', line: 670]},
{:elixir, :erl_eval, 3, [file: 'src/elixir.erl', line: 223]},
{:elixir, :eval_forms, 4, [file: 'src/elixir.erl', line: 211]},
{Code, :eval_string, 3, [file: 'lib/code.ex', line: 168]},
{Kernel.CLI, :wrapper, 1, [file: 'lib/kernel/cli.ex', line: 437]},
{Enum, :"-map/2-lists^map/1-0-", 2, [file: 'lib/enum.ex', line: 1184]}]
-fun-
Elixir 的默认错误消息中的那些,因为它们是
normalized , 至
anonymous fn/0 in Foo.main/0
在这种情况下(这就是为什么我通过显式调用
System.stacktrace/0
来打印上面的堆栈跟踪)。
lists^foldl/2
在哪里?来自?那是
generated by sys_core_fold_lists
, 一个模块
called by sys_core_fold
对于定义
inline_list_funcs
的模块compile 属性(Elixir 中的
Enum
模块
does do that ),它“从列表模块中内联高阶列表函数”。这种内联还为匿名函数提供了名称“lists^foldl/2”,而不仅仅是“有趣”。
defmodule Fold do
@compile :inline_list_funcs
def main do
sum([1, 2, 3])
end
def sum(list) do
:lists.foldl(fn a, b -> raise "foo" end, 0, list)
end
end
Fold.main
@compile :inline_list_funcs
,输出为:
** (RuntimeError) foo
fold.exs:9: anonymous fn/2 in Fold.sum/1
fold.exs:9: Fold."-sum/1-lists^foldl/2-0-"/3
(elixir) lib/code.ex:363: Code.require_file/2
** (RuntimeError) foo
fold.exs:9: anonymous fn/2 in Fold.sum/1
(stdlib) lists.erl:1263: :lists.foldl/3
(elixir) lib/code.ex:363: Code.require_file/2
lists
的任何堆栈跟踪条目。模块,即使我们显式调用
:lists:foldl
.
Why are there multiple
/3
?
Why are some names
-
prefixed?
What does the
^
mean?
sys_core_fold_lists:call/4
选择。
Why the
2-0-
?
2
来自
sys_core_fold_lists:call/4
.
0
是
referred to as "count" in Exception.format_mfa/3
但我不确定这意味着什么。
关于elixir - 如何理解编译好的 Elixir Erlang 函数名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38507755/
我想实现一个 Erlang 解释器,最近我在阅读 Erlang 的标准库源代码。我在 erlang.erl 中找到 erlang:display/1 的源代码是: %% display/1 -spec
我即将用 Erlang 构建一个系统(我的问题可以用多个 CPU 更好地解决),我已经浏览了: 向你学习一些 Erlang; Erlang/OTP 在行动 编程 Erlang(阿姆斯壮); Erlan
我真的很难理解 Erlang 中的尾递归。 我有以下 eunit 测试: db_write_many_test() -> Db = db:new(), Db1 = db:write(f
我不确定或者我不知道 erlang 定位不在默认目录中的模块的传统方式。我知道它会查看已编译的文件夹和 erlang 的系统文件夹或 - lists:foreach(fun (E) -> io:fwr
对 Erlang 完全陌生。我正在尝试为函数组合定义一些函数,例如 compose , juxt和 pipe但是遇到这样一个事实,即 Erlang 没有(据我所知)可变参数,因此很难只编写适用于所有输
在 Erlang 中存储和管理高性能可变对象的最佳方法是什么?假设我想编写具有实时游戏玩法的非常简单的在线游戏服务器。不知何故,我需要在 Erlang 内存中表示玩家的状态。例如,它可能只是一个简单的
警告:前面的 erlang n00b。 我正在尝试掌握 erlang,只是尝试与牛仔一起使用基本的 hello world 应用程序。我正在模拟一个错误,基本上是在我的代码中的某处返回一个无效值,并试
当你向 shell 进程发送消息时,你可以通过调用: c:flush(). 来清除所有消息。 C:\Windows\System32>erl Eshell V5.9(使用 ^G 中止) 1> 自我()
这应该是一个简单的问题,但我不太了解文档,无法找到答案。 如果 OTP 管理器在崩溃后重新启动 gen_server,新子进程是否继承了崩溃进程的消息队列,或者消息是否在崩溃之前发送但尚未由旧子进程处
我将 net_ticktime 值设置为 600 秒。 net_kernel:set_net_ticktime(600) 在 net_ticktime = TickTime 的 Erlang 文档中:
我正在监视一个 Erlang 应用程序,我目前正在尝试确定特定 PID 已经运行了多长时间。绝对时间戳或持续时间对我有用,但我在 process_info 或通过 sys 模块看不到这些数据位中的任何
我想重新定义查找特定单词的元组的顺序 例如,我有一个像这样的元组列表: [{"a",["r001"]}, {"bi",["bidder"]}, {"bo",["an"]}] 但有时元组的顺序可能会
以下几行出现在 http://aosabook.org/en/riak.html 中,在该部分的第二段: 15.1. Erlang 简介 : "Calling the function with a
我认为 Erlang 节点之间的消息不应该很大。如果我想构建一个流服务器,通常每个连接都需要很大的带宽,Erlang 能做好吗?如果是,是否有任何开源代码可供我学习?我了解到 Erlang 很适合处理
下一个代码在结果中给了我 5.999999999999998,但正确答案是 6。 Alpha = math:acos((4*4 + 5*5 - 3*3) / (2*4*5)) Area = 1/2 *
注意:这是我的 previous question 的进化延续。关于类似的话题。 一段时间以来,我一直在寻找有关部署和更新 Erlang/OTP 版本(一组应用程序)的“最佳实践”,但我找不到任何直接
我试图在头文件中指定一个函数。 像这样: -spec update(pid(), tuple(tuple(), integer(), atom()), tuple(atom(), atom())) -
所以我在过去的八个小时里一直在使用 Erlang,我花了两个时间用我的头敲击键盘试图找出我的控制台不断返回的异常错误。 我正在编写一个骰子程序来学习erlang。我希望它能够通过 erlang 解释器
当我编译以下模块时: -module(x). -export([inp/0]). f(X) -> g(X). g(X) -> error(X). inp() -> f(123)
我目前正在开发一个实时媒体服务器,它将允许普通消费者向我们发送实时视频。在我们当前的环境中,我们已经看到发送给我们的广播持续了几天,因此能够在不断开用户连接的情况下修复错误(或添加功能)的想法非常引人
我是一名优秀的程序员,十分优秀!