[Dev-luatex] user_defined whatsits - store function?
taco at elvenkind.com
Thu Sep 9 20:07:53 CEST 2010
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))
> 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.
More information about the dev-luatex