Version 3.1 question...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Version 3.1 question...

Fred Bertsch
Perhaps this was discussed before I signed up for this list, but I missed
it (obviously).

In version 3.1, there is a brief mention of "multiple interpretation
environments" on the FAQ.  That sounds great!  Will there be support for
multiple threads running different Lua environments?  If so, I'd be pretty
happy!  Also, how is it going to work?  Will there be multiple garbage
collectors, or just one Lua memory space?  Is there any way to communicate
between different environments?

Just curious...

Fred

Reply | Threaded
Open this post in threaded view
|

Re: Version 3.1 question...

Roberto Ierusalimschy
> In version 3.1, there is a brief mention of "multiple interpretation
> environments" on the FAQ.  That sounds great!

The support is a very simple one: *All* global variables have been put in a
dynamic structure, so now Lua has only one (1) global variable, which is a
pointer to that structure. You can create many of these structures, and each
one will be a *completely independent* environment. To switch environments,
one only has to switch the value of this global pointer.

> Will there be support for multiple threads running different Lua environments?
Not directly. For real multy-thread you need a way to switch the global
pointer when there is a context-switch. In some systems this may be easy,
in ohters not...

>  Will there be multiple garbage collectors, or just one Lua memory space?
The environemnts will be *completely independent*. Each one has it global
space, memory space, garbage collector structures, etc.

> Is there any way to communicate between different environments?
No, but it can be done via a C library; but it will have the same problems
that comunicating between processes (e.g. how to pass functions).

  The main rationale has been: it is very difficult to make everybody happy,
mostly in a portable way. This solution is very simple, has an almost null
cost, and even not solving some problems it facilitates for each one to
solve individual problems.

-- Roberto