Compilation 为什么Erlang编译:文件不报告未知选项的错误?
调试信息的正确选项是Compilation 为什么Erlang编译:文件不报告未知选项的错误?,compilation,erlang,Compilation,Erlang,调试信息的正确选项是debug\u info: 1> compile:file(hello, [debug_info, export_all]). {ok,hello} 另一方面,我不明白的是,为什么编译总是成功的,在传递不存在的选项时也是如此 比如说 2> compile:file(hello, [debug, export_all]). {ok,hello} 或 为什么这两个示例不报告错误?在Erlang中,忽略无效选项是很常见的。使用默认值获取选项。大概是这样的: 1>
debug\u info
:
1> compile:file(hello, [debug_info, export_all]).
{ok,hello}
另一方面,我不明白的是,为什么编译总是成功的,在传递不存在的选项时也是如此
比如说
2> compile:file(hello, [debug, export_all]).
{ok,hello}
或
为什么这两个示例不报告错误?在Erlang中,忽略无效选项是很常见的。使用默认值获取选项。大概是这样的:
1> Opts = [{opt1, 1}, {other, 2}].
[{opt1,1},{other,2}]
2> %% Inside function
2> Opt1 = proplists:get_value(one, Opts, 1),
2> Opt2 = proplists:get_value(two, Opts, 2).
2
3> Opt1.
1
4> Opt2.
2
5>
1> Opts = [{opt1, 1}, {other, 2}].
[{opt1,1},{other,2}]
2> %% Inside function
2> Opt1 = proplists:get_value(one, Opts, 1),
2> Opt2 = proplists:get_value(two, Opts, 2).
2
3> Opt1.
1
4> Opt2.
2
5>