And using this approach, you can even hide the fact that you are creating locals:
local input = [[
function (cpu)
logger.debug("RLC %s")
cpu.%s = RLC(cpu, cpu.%s)
cpu.PC = (cpu.PC + 2) & 0xffff
end
]]
... somewhere in your code, this can be "ugly" with as many "local" variables as you want:
local s = [[local logger, RLC = ...\n]] .. input
local f = assert(load(s, s, "t", {}))(logger, RLC)