[erlang-questions] Variable bindings

Tyron Zerafa <>
Sun Jan 27 12:11:46 CET 2013


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.

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.


On Sun, Jan 27, 2013 at 9:31 AM, <> wrote:

> > Does there exist any particular function which would give me all variable
> > bindings (including their values) at that point.
>
> Maybe someone has already asked this,
> but why do you want this?
>
> There _are_ programming languages in which this degree
> of runtime introspection is possible: Interlisp and S
> spring to mind.  But that comes at a fairly heavy cost,
> and Erlang does not support it.
> This kind of thing is more commonly found in debuggers.
>
> Is it a debugging task you want this for?
>
> The parse-transform approach that's been mentioned does
> this at compile time, not at run time.  Now consider
>
>    f(X) -> Y = g(X), if Y >  0 -> {{A}} h(Y)
>                       ; Y =< 0 -> {{B}} r(X)
>                      end.
>
> At point {{A}}, an Erlang compiler would normally say that
> Y exists but X doesn't any more.  At point {{B}}, we'd
> normally say that X exists but Y doesn't any more: a
> variable "exists" from its binding time to its last use.
> (If you kept variables around any longer than that, you'd
> be hobbling the garbage collector.)
>
> So I think we might need a clearer idea of what variables
> _you_ expect to exist at a point and whether retaining
> data longer than necessary is acceptable to do.
>
>
>


-- 
Best Regards,
Tyron Zerafa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130127/464c7586/attachment.html>


More information about the erlang-questions mailing list