Re: [Suggestion] Embed bytecode in source code
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: [Suggestion] Embed bytecode in source code
- From: Pat Brown <ptbrown@...>
- Date: 2015年10月08日 12:55:20 -0400
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)