<div dir="ltr"><div>So this means that when you are representing data structures/patterns they should be "as literal as possible"? And only use explicit structures, for example #c_cons{}/#c_tuple{}, when they have elements which aren't literal values?<br><br></div>Robert<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 17 March 2017 at 15:52, Björn Gustavsson <span dir="ltr"><<a href="mailto:bjorn@erlang.org" target="_blank">bjorn@erlang.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, Mar 16, 2017 at 10:59 PM, Richard Carlsson<br>
<<a href="mailto:carlsson.richard@gmail.com">carlsson.richard@gmail.com</a>> wrote:<br>
<br>
> The optimal way to represent literals tends to vary between passes, so<br>
> there's never a clear-cut choice. If you use the cerl.erl module, you'll<br>
> find some utility functions like fold_literal/1 and unfold_literal/1,<br>
> is_literal_term/1, etc., that can take care of the details. For example,<br>
> cons_hd/1 and cons_tl/1 will give you the head subtree even if the argument<br>
> is a literal list.<br>
<br>
</span>It is true that literals may be differently represented<br>
within different passes, but some passes (sys_core_fold,<br>
v3_kernel) make implicit assumptions that a literal<br>
is represented as #c_literal{}. Breaking those assumptions<br>
can lead to sub-optimal code or possibly even compiler<br>
crashes.<br>
<br>
/Bjorn<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Björn Gustavsson, Erlang/OTP, Ericsson AB<br>
</font></span></blockquote></div><br></div>