首页 > 解决方案 > elixir:eval_forms 和 elixir_compiler 中 compile 的区别

问题描述

elixir_compiler.erl(和其他一些地方)代码的编译以两种不同的方式完成。以下代码在两者之间切换:

 eval_forms(Forms, Args, E) ->
  case (?key(E, module) == nil) andalso allows_fast_compilation(Forms) of
    true  ->
      {Result, _Binding, EE} = elixir:eval_forms(Forms, [], E),
      {Result, EE};
    false ->
      compile(Forms, Args, E)
  end.

据我了解,一个通过构建编译模块并执行“编译功能”来编译代码,另一个使用作为erl_eval某种解释器的模块。我想知道的是为什么编译代码有两种不同的方式以及如何选择方式。

标签: compiler-constructionerlangelixir

解决方案


推荐阅读