I believe this can be done. We can enclose all the VM state variables
into a structure, then pass that structure into the functions that need
it. Each function would then perform its task inside the specified VM.
Since we're not working with multiple processes, each VM context can
work with variables from other VMs. It might look like this in C:

VM* vm_a = rb_vm_context_new();
VM* vm_b = rb_vm_context_new();

rb_define_global_const(vm_a, "hello", rb_str_new2("Hello!"));
rb_define_global_const(vm_b, "hi", rb_str_new2("Hi!"));

rb_eval_string(vm_a, "$hello"); // "Hello!"
rb_eval_string(vm_a, "$hi");    // Qnil
rb_eval_string(vm_b, "$hello"); // Qnil
rb_eval_string(vm_b, "$hi");    // "Hi!"


We can use it within Ruby somewhat like this:
https://gist.github.com/timahoney/5197905

Is it a possibility?

-- 
Posted via http://www.ruby-forum.com/.