[CM] Question about migrating values between interpreters
Wouter Bijlsma
wouter.bijlsma at icloud.com
Thu Feb 26 09:53:17 PST 2026
Hello,
I’m just starting out using s7 to embed scripting capabilities in my application, so I don’t really have a very deep understanding of s7 internals yet. So apologies in advance if my question has a very obvious answer.
What I’m wondering is whether s7 has a way to migrate or copy values (s7_pointer) between different s7_scheme interpreters? The reason I would want this is because in my application all scheme-related operations are scheduled as fibers running on a thread pool, where each thread has its own s7_scheme interpreter. I would like to persist s7_pointers on the host side (by protecting them from GC), and re-use them between calls, but since the fiber scheduler has no way to force which thread will evaluate an expression, persisted values may not belong to the s7_scheme that wants to operate on them.
The straightforward solution I thought of is to track the s7_scheme each persisted value belongs to, and if if a thread wants to use it with a different s7_scheme, serialize the value to a string, then eval that in the other s7_scheme to copy it. This would probably work but seems more expensive than necessary compared to directly copying the cell indicated by the s7_pointer and all other cells it references.
Does s7 have something like that or is the serialize/eval approach the ‘correct’ way to do this? Or am I missing some alternative method?
Thanks, Wouter
More information about the Cmdist
mailing list