From e10a33a3b14494a14e44d520b69bfc196e1d7eca Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 26 Aug 2021 11:05:52 +0300 Subject: [PATCH] add use function to standard lib --- lib/utils.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/utils.lua b/lib/utils.lua index 16c4257..814ee56 100644 --- a/lib/utils.lua +++ b/lib/utils.lua @@ -55,3 +55,13 @@ function round(x, n) if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end return x / n end + +function use(module, ...) + for k,v in pairs(module) do + if _G[k] then + io.stderr:write("use: skipping duplicate symbol ", k, "\n") + else + _G[k] = module[k] + end + end +end