lua-users home
lua-l archive

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



Am 02.12.2012 um 00:51 schrieb Kevin Martin:


On 1 Dec 2012, at 23:30, Philipp Kraus wrote:

Can I modify eg array structures without copying into the Lua stack?

Yes, I think the simplest way, assuming your array structure won't got out of scope during the life of the Lua state, is to use a light user data (the address of array) stored in a c closure for each operation you want to perform on the array. One for get and one for set I imagine?

Yes and the function call.

You would then call your script with the closures (functions) as arguments.

Seems to be a nice feature, because I would like to pass linear algebra structures to the script and the script should modify, so I don't need to copy the data first and copy the return back into the structure and I don't create any duplicated memory.

Thanks for your explanation

Phil