[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: [Suggestion] Embed bytecode in source code
- From: "Soni L." <fakedme@...>
- Date: Tue, 6 Oct 2015 11:14:47 -0300
As of Lua 5.3 you can add a #! line to a precompiled bytecode file and
it'll parse and run.
Seeing as how insane that is, can we get to embed bytecode in source
code? As in:
load(string.format("f = %s f(print, 'hello world!')",
string.dump(function(pf, v) pf(v) end)))()
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)
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.