lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


[Charset ISO-8859-1 unsupported, filtering to ASCII...]
> Hi all,
> 
> In order to create muiltiple lua global environment, I wonder which 
> part of sturctures/funtions of lua I should study. 
> The intention of that is, I would like to experiment a C++ object, 
> with a ability of creating/interacting/keeping [privately] it's own 
> lua gloabl environment. 
> 
> What I can think of is:
> 
> A C++ class:
> ------------
> Class person{
>   Fields...
>   lua_State *MyL;   // for Scripting this person's behavior!
>   methods...
> };
> Or
> using lua_object, and how?!
> 
> am I right?! sorry for being naive!!
> 
> And I want to create, 10,000 of them (at least!!), and see how the 
> performacne would be!!
> 
> Even though, I believe, it would be enough to have only one lua 
> global environment, I would like to try out this new feature (allow 
> to create multiple lua global environment) in verion 4.0.
> 
> Any Comment? Anyone actually has done that? Thanks!
> 

You may want to look at the TCL source[1] for ideas.  Tcl allows
multiple interpreters to exist in a single process.  This lets you do
the kind of thing you describe[2], but the down side is you have to pass
a pointer to the interpreter structure to EVERY function you define in
C.  Actually, you get used to it after a while.

I wish python had the same feature.

-- cary

[1] Earlier versions of TCL (7.x) are much more compact and may be easier
to follow.  But in general the TCL implementation code I have looked at
has been done very nicely.

[2] As I understand each interpreter is completly separate.