It's an interesting question all right. What's the purpose of the
"migration"?
Technically speaking, a closure is just a pair of pointers to its
code and
its environment. You could create a new "foreign reference" type (tag)
that
would cause these to be looked up on the original computer whenever you
needed
them. That would handle synchronization. Of course, you could also
make copies
of everything. I think tags are constant over all architechtures (last
I looked)
but there are run-time allocated types that you'd have to do some work for
(I think - I don't remember what they're called).
Anyway, besides taking care of the tags/synchronizing run-time
allocated types/
handling endianness issues, you'd need to munge pointers according to
whereever
they would be newly allocated on the new machine. It would probably be
easiest
to just number copies of the cells from 0 to whatever for the transport
over and the
allocator on the other end could relabel them to the actual values.
Also, you'd need to check that any symbols referenced by the code or
variables were
actually in existence in the new guile instance's symbol table. And
that global
variables referenced by the code got copied (as well as the lexical
variables).
So will be recursively nasty.
Good Luck.
Lynn
Greg Troxel wrote:
1. If I have a scheme value that is a closure, is there any way that
I can
serialize this closure (from C code) into a form that it can be
deserialized back into a SCM closure variable (again, by C code)? I
can
assume for this question that both ends of the serial line are
running the
same version of gnu guile and my software, but cannot assume that both
ends are running on the same computer architecture. Would it instead
only be possible for me to transfer closures as their scheme source.
I'm not even sure it is well-defined what it means to migrate a
closure. Should a mutation on the new computer of a captured variable
affect the old computer?
_______________________________________________
Guile-user mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/guile-user