Gen_statem receiving data

“reply” in Erlang (not Elixir) is a list of 5 characters and syntactical sugar for [$r, $e, $p, $l, $y] . Each list element is a cons cell with a character in the head and the tail pointing to the next cons cell. A character is the Unicode code point value for the character. A cons cell is 2 machine words. Thus “reply” needs 10 words of storage.

An atom needs the string value, 5 bytes, and some overhead in the global atom table, and then one word whereever it is refered to.

5 Likes

@raimo Thank you for the explanation, that’s so helpful

1 Like

That made flashbacks for me to the linked list in Turbo Pascal, it’s the same mechanism