lua-users home
lua-l archive

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


Hi, suppose I have a file containing data like:

return {

    {
        name='foo',
        val=42,
        _onA_ = function(x)
            return doSomething(x)
        end,
    },

    {
        name='bar',
        val=123,
        _onA_ = function(x)
            return doSomethingElse(x)
        end,
        _onB_ = function(x)
            return doAnotherThing(x)
        end,
    },

}


I want to read in the file, manipulate some of the members (like name, val), and then write it out again. But I want to preserve the functions (onA, onB) as they are.

Any tips for how to do this?

I guess I can easily write out the data structures and known members by just writing them out (since I know them) and then try to grab the raw text of the functions from the original input file and write that out in the appropriate place. Is that a good idea? Maybe the debug library can help?

Suggestions?