Beam label 0 special?

Bjorn Gustavsson bjorn@REDACTED
Mon Jun 26 15:38:02 CEST 2006


Andrew Lentvorski <bsder@REDACTED> writes:

> Does label 0 have a special meaning in BEAM code similar to the way
> atom 0 does?

In a way, yes. {f,0} means that if an error occur in execution of the
instruction, an exception should be generated (whereas if {f,LabelNumber}
is given, execution will continue at {label,LabelNumber} if an error
occurs).

(Label 0 is not allowed to be defined.)

> 
> nil is always atom 0 even though it is not listed in the atom table, right?

If you refer to [] (empty list), yes. This is just an encoding trick in Beam
files to make the Beam files smaller. The Beam loader does the translation to
[] at load time.

/Bjorn

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list