[erlang-questions] Did Erlang's grammar change in R16A?

Richard A. O'Keefe ok@REDACTED
Fri Feb 15 00:14:42 CET 2013

On 15/02/2013, at 11:42 AM, Björn-Egil Dahlberg wrote:
> If I'm reading [EEP 20] correctly: a local atom would actually require a larger heap space than an equivalent heap binary .. which is a feat all by itself.

A 'local atom' uses the same space *per reference* as existing atoms do.
On the heap of the process that created it,
it holds the bytes of the name plus a 3-word header (32-bit machine design).
The minimum imaginable overhead would be a 1-word header, and that
would sacrifice some of the efficiency that the 3-word header allows.

Now, I'm looking at an elderly (R12B-5) set of sources (on an elderly machine),
and I see that
 - a ProcBin requires 6 words on the process's heap
 - a Binary requires a 3-word header plus the bytes,
   or on a 32-bit machine, a 4-word header plus the bytes.
I believe a Binary is the "equivalent heap binary" you are talking about.

So no, a local atom would NOT require larger heap space than a binary.
Why did you think it would?

> I agree that atom gc is needed but it shouldn't be an excuse for using dynamic atoms instead of binaries. 

On the one hand, it isn't.  The EEP is very explicit that the goal is _safety_ rather than _convenience_.

However, haven't we had enough complaints about the confusion between lists of integers
and strings of text?  Don't you think that a clean distinction between a sequence of bits in some
unknown encoding and a chunk of text in a known encoding is useful?

> Besides, if locals atoms are larger than binaries why would you use atoms. (I might be wrong about the size though .. didn't look that hard).

Oh, if people are bigger than houses, we should all use Perl.

More information about the erlang-questions mailing list