[erlang-questions] Current term representation?

Mikael Pettersson mikpe@REDACTED
Tue Jul 15 10:56:22 CEST 2008


Richard A. O'Keefe writes:
 > On 15 Jul 2008, at 6:23 am, Richard Carlsson wrote:
 > > Look in the file erts/emulator/beam/erl_term.h for the tag
 > > scheme; the comments are fairly detailed.
 > 
 > I was aware of that file, but there is a lot of detail not
 > explained, and there's one detail I have a hard time believing.
 > Can it really be true that empty tuples {} are heap allocated
 > "boxed" objects?

Yes. They always have been, ever before the "new" tag scheme.
It's my impression that they're not common enough in Erlang
to warrant an immediate type tag, unlike say SML which makes
heavier use of empty tuples. Also, adding a special case to
the tuple representation would no doubt complicate the runtime
system's C code, or at least require a very careful audit.

 > > > In particular, how are funs represented?
 > >
 > > The definition of the struct ErlFunThing is found in the file
 > > erts/emulator/beam/erl_fun.h.
 > 
 > Thanks.  I'd missed that one.
 > 
 > As for the rest, it's what I _thought_ was the case, but I was
 > hoping I was wrong.

By "the rest" do you mean terms in general or just funs?
If terms in general, what were you hoping to be wrong?



More information about the erlang-questions mailing list