[erlang-questions] Variable bindings
Sat Jan 26 17:16:14 CET 2013
On Sat, Jan 26, 2013 at 4:32 PM, Tyron Zerafa <>wrote:
> Does there exist any particular function which would give me all variable
> bindings (including their values) at that point.
I don't think that it's possible to retrieve such information when running
compiled code. After all the transformations and optimizations are
performed by the compiler, the actual variables in the program may be
different form those declared in the source code.
For example, consider this code:
Y = X,
The value of Y will most surely be propagated to its use in max/2 thus
eliminating the variable from the final compiled code altogether.
So all you could theoretically access at runtime would be the actual
variables in the function's call frame in the stack. However, this is done
by the erts emulator and I don't believe this is possible from within
One way to work around this would be to manually store the bindings, for
example, in a dictionary so you can perform lookups at will. However, that
means that there would be overhead due to the stores and lookups and also
require more memory.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions