Difference between elixir:eval_forms and compile in elixir_compiler

Viewed 52

In elixir_compiler.erl (and some other places) the compilation of the code is done in two different ways. The following code switches between the two:

 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.

As far as i understand one compiles the code by building a compile module and executing a "compile function" and the other uses the erl_eval module which is some kind of interpreter. What i would like to know is why there are two different ways the code is compiled and how the way is chosen.

0 Answers
Related