lua-users home
lua-l archive

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


On Fri, 21 Apr 2000, Martin Dvorak wrote:

> Let's say I have thousands of objects in my application
> and I would like to create individual environment (or state)
> for each object, so that objects cannot interfere between
> each other. 
>
> Does anyone have a better solution?

You can set tag methods so that when you get a global or set a global
variable, it must go through your code.  Thus, you can make it so that an
individual object can only save their state in a location that you choose.  
Look up the tag methods "getglobal" and "setglobal".

If you use a technique similar to this, then you wouldn't have to have a
complicated C message passing system.

Incidentally, if you're worried about security, and you want to
completely prevent objects from talking to each other without your code 
controlling it, you should be aware that there is an undocumented
global string (_VERSION).  You have to watch out for global numbers,
strings, and tables and userdata with default tags, because you can't
change the "setglobal" tag on them.  You might check out the documentation
for the code that I posted yesterday:  

http://mems.ee.cornell.edu/Fred/Resume/CodeSamples/Conversations.html

It does something somewhat similar to prevent unauthorized communication,
but it does not do the other things you're hoping for.

F