From: Tony Arcieri Date: 2013-03-20T02:25:58+09:00 Subject: Re: Multiple environments in a single process --047d7b3a8ab8fa276f04d84a653f Content-Type: text/plain; charset=ISO-8859-1 Might want to read this thread. It provides a bit of a post mortem on MVM. There were big plans to do this in like 2008 but they all fizzled out: http://www.ruby-forum.com/topic/1450200 On Tue, Mar 19, 2013 at 10:17 AM, Tim Mahoney wrote: > 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/. > > -- Tony Arcieri --047d7b3a8ab8fa276f04d84a653f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Might want to read this thread. It provides a bit of a pos= t mortem on MVM. There were big plans to do this in like 2008 but they all = fizzled out:

http://www.ruby-forum.com/topic/1450200


On Tue,= Mar 19, 2013 at 10:17 AM, Tim Mahoney <lists@ruby-forum.com> wrote:
I believe this can be done. We can enclose a= ll 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 =3D rb_vm_context_new();
VM* vm_b =3D rb_vm_context_new();

rb_define_global_const(vm_a, "hello", rb_str_new2("Hello!&qu= ot;));
rb_define_global_const(vm_b, "hi", rb_str_new2("Hi!"));=

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


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

Is it a possibility?



--
= Tony Arcieri
--047d7b3a8ab8fa276f04d84a653f--