lua-users home
lua-l archive

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

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.