1 -- WARNING, this is undertested, especially in cases where mutliple
2 -- modules have thei own fenvs. Use at your own risks, or test/debug
3 -- for the whole community's benefits :)
5 --print'xglobal\'s args' table.print{...}
7 local function decl_builder(x)
8 local ids, vals = unpack(x)
9 local ids_as_strings = table.imap(|x| `String{x[1]}, ids)
10 local decl = `Call{ +{getmetatable(getfenv()).__newglobal},
11 unpack(ids_as_strings) }
12 if vals then return { decl, `Set{ ids, vals } }
16 mlp.lexer:add 'global'
17 mlp.stat:add{ 'global', mlp.id_list, gg.onkeyword{ '=', mlp.expr_list },
18 builder = decl_builder }
20 +{ require -{ `String{ package.metalua_extension_prefix .. 'xglobal-runtime' } } }