<br><div class="gmail_quote">On Sat, Jan 26, 2013 at 4:32 PM, Tyron Zerafa <span dir="ltr"><<a href="mailto:tyron.zerafa@gmail.com" target="_blank">tyron.zerafa@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>Does there exist any particular function which would give me all variable bindings (including their values) at that point.<br></div></div>
<br></blockquote></div><br>Hello!!<br><br>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.<br>
<br>For example, consider this code:<br><br>foo(X) -><br> Y = X,<br> max(Y, 42).<br><br>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.<br>
<br>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 Erlang code.<br>
<br>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.<br>
<br>Aggelos<br>