From: Thorsten Scheuermann Date: 2002-06-10T23:05:06+09:00 Subject: RE: multiple instances of Ruby interpreter in my C++ code? I wanted to use it in a module for an application to run (currently) very simple scripts. The thing is that the app is multithreaded and several instances of this module could run concurrently executing different scripts. The scripts right now just look like this: doSomething(x) doSomethingElse(A_CONSTANT) ... They are automatically generated but eventually I will write new ones by hand and that's where the flexibility of Ruby would come in handy. the calls that are made in the scripts end up calling wrapped C/C++ functions. If I have something like script1: x = foo() script2: x = bar() I don't want the scripts to actually share the variable x. They should be visible only in the scope of the particular script. Maybe there's a way of wrapping these scripts inside a Ruby module through a preprocessor so that they are isolated from each other? -Thorsten -----Original Message----- From: Sean Middleditch [mailto:elanthis@awesomeplay.com] Sent: Monday, June 10, 2002 9:49 AM To: ruby-talk@ruby-lang.org Subject: Re: multiple instances of Ruby interpreter in my C++ code? Ruby makes use of a lot of global values - there is no way of doing this in Ruby currently. What reason do you have for wanting multiple instances? There may be another way of accomplishing your goal(s). On Mon, 2002-06-10 at 09:42, Thorsten Scheuermann wrote: > Hi, > > I'm new to Ruby and am currently trying to embed Ruby in a C++ program. It > is pretty straightforward and I've already had some success with that. > However, what I really want is to have several independent instances of the > interpreter running. Lua for example makes this easy by encapsulating the > interpreter state in a C struct, but I didn't see that facility in Ruby. Is > there any way to accomplish this? > > -Thorsten Scheuermann