gpt4 book ai didi

intellij-idea - Erlang 故障转储正在写入 : erl_crash. 转储...完成

转载 作者:行者123 更新时间:2023-12-04 05:44:09 25 4
gpt4 key购买 nike

所以我才开始学习一些基本的 Erlang。我正在研究 IntelliJ Idea。我写了一个基本函数来添加两个数字:

-module(easy).
-author("var").

%% API
-export([add/2]).

add(X, Y) ->
X + Y.

但是当我运行它时,出现以下错误:

{"init terminating in do_boot",{{badmatch,{error,{1,erl_parse,["syntax error before: ","','"]}}},[{init,start_it,1,[]},{init,start_em,1,[]}]}}

Crash dump is being written to: erl_crash.dump...done
init terminating in do_boot ()

我似乎无法弄清楚为什么会这样。与Idea的Run config有关吗?

最佳答案

不确定您如何执行代码。尝试按照这些步骤操作。

创建包含源代码的文件,在本例中为 easy.erl,您已经拥有该文件:

[g@somecomp:~/test]$ cat easy.erl 
-module(easy).
-author("var").

%% API
-export([add/2]).

add(X, Y) ->
X + Y.

现在编译模块:

[g@somecomp:~/test]$ erlc easy.erl

启动 Erlang 并从 shell 加载它:

[g@somecomp:~/test]$ erl
Erlang/OTP 18 [erts-7.2.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.2.1 (abort with ^G)
1> l(easy).
{module,easy}

在 shell 中执行函数并关闭 Erlang:

2> easy:add(1,2).
3
3> q().
ok
4> [g@somecomp:~/test]$

或者,您可以直接从 shell(bashcsh)执行它,但在那种情况下您必须显式打印出返回值:

[g@somecomp:~/test]$ erlc easy.erl
[g@somecomp:~/test]$ erl -noshell -eval 'io:format("~p~n", [easy:add(1,2)])' -s init stop
3
[g@somecomp:~/test]$

关于intellij-idea - Erlang 故障转储正在写入 : erl_crash. 转储...完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35475516/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com