lua-users home
lua-l archive

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


On Tue, May 21, 2013 at 8:14 AM, Thomas Jericke <tjericke@indel.ch> wrote:
If Lua really once will get a macro extension, it is highly possible that such things would be possible, assuming that the Lua macro language will run pre-compilation.

Naturally, this has been done ;)

--- mmath.lua
-- shows how a macro module pulled in with require_
-- can return a substitution value. In this case,
-- it would be better to use include_, but this
-- method is more general
return function()
    return 'local sin,cos = math.sin, math.cos\n'
end

-- test-require.lua
require_ 'mmath'

print(sin(1.2) + cos(0.3))

Anything can be loaded at pre-compile expansion time, so it can work with any require.

However, it involves the external dependency LuaMacro as a preprocessor