9 Sep
2010
9 Sep
'10
6:07 p.m.
On 09/09/2010 07:17 PM, Patrick Gundlach wrote:
this is how I store the function:
n.value = string.dump(function() print("a") end)
and this is how I read it:
fun = assert(loadstring(head.value)) fun()
I guess that n.value "chokes" on \0 in strings.
Yes, and that is because internally the user_defined node has no room to store the string length in. I can fix that (later), but it is not intended usage and regardless it does not help you right now.
So any idea on how to store a function?
Put the functions in a global lua table and store the index to it? That allows upvalues, and faster too if the function is non-trivial. Best wishes, Taco