lua-users home
lua-l archive

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


On Tuesday, October 06, 2015 11:14:47 AM Soni L. wrote:
> sourcecode_part = "f = %s f(print, 'hello world!')"
> bytecode_part = string.dump(function(pf, v) pf(v) end)
> combined_parts = string.format(sourcecode_part, bytecode_part)
> loaded_function = load(combined_parts)
> loaded_function() --> prints "hello world!"
> 
> (Note: Code shown here doesn't (yet) work, it's just an example)

Doesn't work because you're not using %q. Change sourcecode_part to
"f = load%q f(print, 'hello world!')".

-- 
(Pat Brown)