lua-users home
lua-l archive

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


Thanks to you and everyone else who's responded so far, these were all
very quick and helpful answers.

On Thu, May 6, 2010 at 12:50 AM, Patrick Donnelly <batrick@batbytes.com> wrote:
> So the point he was making is that if you have identical huge strings
> defined in multiple functions then your precompiled byte code will be
> unnecessary large (as a result of the above). I think you may find it
> better to just have your program A save the compressed source code for
> each chunk rather than precompile it. In past discussions on this
> list, this has been the suggested route.

Thanks for the suggestion.  I see in the list archives someone posted
a technique for gzip-based decompression immediately before
luaL_loadbuffer(), I'm assuming that's what you were referring to (or
was close enough).  Perhaps I'll be able to integrate something like
that.

I realized that for some of these dumped chunks, the comment-scrubbed
source code would actually be smaller, so I may also be able to save
space by only precompiling the ones that yield smaller chunks than
source code!  luaL_loadbuffer()'s willingness to take either source or
dump makes this approach very simple.

> Strings are interned, yes. Lhf was referring to function's needing to
> be able to construct their constants (strings in this case) upon
> loading. Said differently, the parser doesn't care that another
> function defined in the same chunk has the same constant (string), it
> remakes the constant in the new function's prototype. However, when
> all of the functions are loaded, the loaded constant strings will all
> be the same.

Gotcha.  So now, just out of simple curiosity for the Lua language and
its features, I'm still wondering if my initial approach could even be
performed.  Irrespective of any memory savings, and instead in the
vein of learning more, can what I was considering be done in a
reasonable way?

To quickly restate the problem for any new readers:  I'd like to make
a table full of loaded chunks (of type LUA_TFUNCTION, not
string.dump()-style payloads) and somehow dump that table for
subsequent inspection/execution in a lua_State in a different process.
 I got hung up on how to create the table as a local inside a
function, since you can only call lua_dump() on a function.

Thanks and best regards,
Charles Nicholson