lua-users home
lua-l archive

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


Let's say that I have a Lua state. Let's say that I have a pile of .lua
files sitting on disk.

Let's say that for each file, I have created a unique table, set a
global 'self' to that table, and then run dofile(). Each unique chunk of
code has leaned on 'self' to populate the table. (And some of them may
have spewed junk into the global table, too). 

Then, let's say that I've run a bunch of code that has modified the
State.

Now, let's say that I want to do something as nebulously-defined as
"Reload all the scripts from disk, but keep the current mutated State."
What insurmountable problems are going to prevent this from working in
any reasonable fashion?

Since some of the state-mutating code that I ran did something like:
  _G.cache[ someLightUserDataObject ] = oneOfTheTablesICreatedForAFile
I'd prefer to try and re-use the tables. (Also, if any of the custom
code has mutated the state by adding/modifying properties in the table,
those are desireable.)

Some of the code also does stuff like:
  someTable[ someKey ] =
oneOfTheTablesICreated.someKeyThatIsAFunctionValue

I'd love it if there was a way, when re-running the files on disk, if
such function references either continued to work, or there was a way to
fix them up after the fact (based on the name of the key in the table
that referred to it). Is this one of those insurmountable problems, or
can I play games with the State before and after the reload to make this
happen?

(Although I understand the motivation, it's not me personally who has
this softly-defined desire...it's a customer. I'm hoping to either find
a way to make things work well enough, or else clearly explain what
makes this technically impossible (or at least infeasible).)

Thanks for any advice or shouts of "That just doesn't even make any
sense!" you can offer.