[erlang-questions] Core erlang definition

Björn Gustavsson bjorn@REDACTED
Fri Mar 17 15:52:15 CET 2017


On Thu, Mar 16, 2017 at 10:59 PM, Richard Carlsson
<carlsson.richard@REDACTED> wrote:

> The optimal way to represent literals tends to vary between passes, so
> there's never a clear-cut choice. If you use the cerl.erl module, you'll
> find some utility functions like fold_literal/1 and unfold_literal/1,
> is_literal_term/1, etc., that can take care of the details. For example,
> cons_hd/1 and cons_tl/1 will give you the head subtree even if the argument
> is a literal list.

It is true that literals may be differently represented
within different passes, but some passes (sys_core_fold,
v3_kernel) make implicit assumptions that a literal
is represented as #c_literal{}. Breaking those assumptions
can lead to sub-optimal code or possibly even compiler
crashes.

/Bjorn

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list