【问题标题】:Erlang Crash Dump is being written to: erl_crash.dump...doneErlang Crash Dump 被写入:erl_crash.dump...done
【发布时间】:2016-05-30 06:25:39
【问题描述】:

所以我刚开始学习一些基本的 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 的运行配置有关?

【问题讨论】:

  • 我刚刚在本地测试了代码,运行良好。问题必须与环境/配置有关。抱歉帮不上忙。
  • 是的,我认为我的配置/环境存在一些问题。试图弄清楚我们的。不过谢谢!

标签: intellij-idea erlang


【解决方案1】:

不确定如何执行代码。尝试按照以下步骤操作。

创建包含源代码的文件,在本例中为 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]$

【讨论】:

    猜你喜欢
    • 2022-01-04
    • 2016-04-12
    • 1970-01-01
    • 2017-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-03
    相关资源
    最近更新 更多