<div dir="ltr">I want to build a call which accepts a fun, extracts all of its code and dependencies, pass everything over to a remote node and execute it there. The only problem I am having is extracting the value of the free vars of such fun. I was thinking about adding these to the parameter list of the fun, i.e shadowing the respective vars. I believe that the parse transform may work at compile time, though I still have to try it out. <div>
<br></div><div style>I do not want to retain data longer than necessary since all I want is to pass the environment values to a remote node. I am not changing in any way the original fun I am transferring between nodes. Having said so, this is the first part of my project and I still have not given much thought about the possibility of unserializable vars type such as file handlers etc.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jan 27, 2013 at 9:31 AM, <span dir="ltr"><<a href="mailto:ok@cs.otago.ac.nz" target="_blank">ok@cs.otago.ac.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">> Does there exist any particular function which would give me all variable<br>
> bindings (including their values) at that point.<br>
<br>
</div>Maybe someone has already asked this,<br>
but why do you want this?<br>
<br>
There _are_ programming languages in which this degree<br>
of runtime introspection is possible: Interlisp and S<br>
spring to mind. But that comes at a fairly heavy cost,<br>
and Erlang does not support it.<br>
This kind of thing is more commonly found in debuggers.<br>
<br>
Is it a debugging task you want this for?<br>
<br>
The parse-transform approach that's been mentioned does<br>
this at compile time, not at run time. Now consider<br>
<br>
f(X) -> Y = g(X), if Y > 0 -> {{A}} h(Y)<br>
; Y =< 0 -> {{B}} r(X)<br>
end.<br>
<br>
At point {{A}}, an Erlang compiler would normally say that<br>
Y exists but X doesn't any more. At point {{B}}, we'd<br>
normally say that X exists but Y doesn't any more: a<br>
variable "exists" from its binding time to its last use.<br>
(If you kept variables around any longer than that, you'd<br>
be hobbling the garbage collector.)<br>
<br>
So I think we might need a clearer idea of what variables<br>
_you_ expect to exist at a point and whether retaining<br>
data longer than necessary is acceptable to do.<br>
<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Best Regards,<div>Tyron Zerafa</div>
</div>