Ok, back on this subject; I ve implemented kind of erlang Actors in Haxe.
Now the problem I face is serialisation of these actors (which are based on closures). The reflect Api do not allows me to 'see' the variable of an anonymous function.
Is there any mean for me to obtain this?

basic example: if I have something like this:

    static    public    function impact (val)
    {
        return function (mess)
        {
            trace("Impact state");
            trace(val);

            return new Cont(idle());
        };
    }

Once the function called, I get an anonymous function which captured the val variable.
I would like to serialise this and be able to restore it on need.

You might want to try neko.Lib.serialize.
See documentation here : http://nekovm.org/doc/view/serialize
Please notice that you can't modify your code then reload serialized closures since their offset in the bytecode might have been changed.

Another possibility that would work for me is to know the original function that was called + its parameters... Is this possible? (I think it depends on the underlying representation of closures).

You might be able to wrap your class with and haxe.Proxy in order to intercept all calls being made. It's not a very well documented feature but you can search on the haxe mailing list archives for examples.

Best,
Nicolas

--
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to