compilation - 为什么Erlang编译:file does not report error for unknown options?

标签 compilation erlang

调试信息的正确选项是debug_info:

1> compile:file(hello, [debug_info, export_all]).
{ok,hello}

另一方面,我不明白的是为什么编译总是成功,而且在传递不存在的选项时也是如此?

例如

2> compile:file(hello, [debug, export_all]).
{ok,hello}

3> compile:file(hello, [foobar, 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>

关于compilation - 为什么Erlang编译:file does not report error for unknown options?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43954074/

相关文章:

emacs - 在 src 中带有嵌套文件夹的 Erlang flymake 找不到包含文件夹

iOS 构建在编译时失败,出现问题 "failed to find a suitable device for the type SimDeviceType"

c - 链接 C 代码失败

c++ - Eclipse C++编译警告问题

groovy - groovyc 是如何工作的?

compilation - : run compiled elixir binary in iex console

java - Gradle 在错误的 Maven 位置搜索 Ormlite?

syntax - io :format and io:fwrite in Erlang? 有什么区别

objective-c - 将 Cocoa 前端编写到 Erlang 应用程序的好方法是什么?

erlang - 无法让 httpc 基本身份验证示例与 https 一起使用