Am 09.09.2010 um 18:29 schrieb Patrick Gundlach:
While I am at the user_defined whatsit. Is there a way to store a function? I can dump the function to a string, but that doesn't sound too efficient. The manual states that the table is a token list, so I am not trying to do
n.value = { function () do whatever I want until the end }
Any ideas?
my idea with string.dump somehow doesn't work for two reasons: 1) the dumped string must not contain upvalues (lua limitation) 2) i get an error when loading the string back: "binary string: unexpected end in precompiled chun k" 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. So any idea on how to store a function? Patrick