[erlang-questions] when any why to use improper lists

Dmitry Belyaev be.dmitry@REDACTED
Fri Jun 29 02:23:38 CEST 2018

It's a way to reduce memory footprint.

Tuple of size N is roughly represented in memory as an array [TupleTag, N,
TupleElement1, TupleElement2, ..., TupleElementN].
Compare it to Cons cell representation: [ConsTag, HeadElement, TailElement]
- it saves 1 word per structure.

Kind regards,
Dmitry Belyaev

On Fri, Jun 29, 2018 at 9:50 AM, Karlo Kuna <kuna.prime@REDACTED> wrote:

> dealing with digraph module i have noticed use of improper lists as
> representations of edges:
> ['$e' | 123]
> is there a good reason to use improper lists instead of tuple for this and
> in general
> when is a good idea to use improper lists?? (i can't think of example for
> justified use)
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180629/65e28613/attachment.htm>

More information about the erlang-questions mailing list