lua-users home
lua-l archive

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


On 17 April 2010 10:56, Linus Sjögren <thelinx@unreliablepollution.net> wrote:
> Thanks for the feedback.
> After a bit of messing around, I think I have a working way to serialize
> functions. My tests have been successful.
> If it works for your needs, I'll tag 1.0.1.
>
> On 17 April 2010 02:16, Joe Andresen <joe.andresen@gmail.com> wrote:
>>
>> This looks like an alternative to table.save
>> although i notice you cannot store functions... this has always been an
>> issue.
>> -J
>> On Fri, Apr 16, 2010 at 4:44 PM, Linus Sjögren
>> <thelinx@unreliablepollution.net> wrote:
>>>
>>> I just tagged the first stable release of luaSolidState.
>>> It is a module that allows painless storage of tables in Lua.
>>> The code is public domain, so you may use it however you want. (But
>>> backports are appreciated)
>>> Project site: http://github.com/TheLinx/luaSolidState
>>> Rockspec
>>> (1.0.0): http://github.com/TheLinx/luaSolidState/raw/rocks/luasolidstate-1.0.0-1.rockspec
>>> Rockspec
>>> (unstable): http://github.com/TheLinx/luaSolidState/raw/rocks/luasolidstate-unstable-1.rockspec
>>> I'd appreciate if those Rockspecs are added to the LuaRocks repository.
>>> I also appreciate any feedback you might have, as well as any bug
>>> reports.
>>> Thank you.
>
>

There are many things you still need to do before you can really say
you're serialising functions (first you'll need to look at upvalues,
also you'll need to bail out if the function is a C function.)
Also I think you'll have problems with cyclical tables; in general
you're not handling duplicate objects at all....
Also performance of your table serialisation leaves much to be
desired: I'm not sure what your addString function is trying to
achieve; but simply adding everything to a table then using
table.concat beats everything else by far.

Also also, I commend you for your localisation of standard library
functions, but pick some easier to read names next time!
(additionally, get to know the # operator)