[erlang-questions] Core erlang definition

Robert Virding rvirding@REDACTED
Fri Mar 17 20:31:53 CET 2017

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


On 17 March 2017 at 15:52, Björn Gustavsson <bjorn@REDACTED> wrote:

> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170317/f11dab1a/attachment.htm>

More information about the erlang-questions mailing list