Moonscript is definitely interesting -- unfortunately I'm one of those programmers with strong opinions about what feels 'right' and 'wrong'. I'm just not terribly in love with the languages that compile to other languages thing...
local import =
function (t, ...)
require('debug')
local pref, keys
if select('#', ...) > 1 or (... ~= nil and type(...) == 'table') then
keys, pref = ...
else
pref, keys = ...
end
keys = keys or {}
pref = pref or ''
if not next(keys) then
for k in pairs(t) do
table.insert(keys, k)
end
end
local new_env = setmetatable({}, { __index = _ENV })
for _, k in pairs(keys) do
new_env[pref .. k] = t[k]
end
debug.setupvalue(debug.getinfo(1, 'f').func, 1, new_env)
end
import(string, { 'reverse', 'rep', 'sub' },'s')
print(sreverse('cat'), srep('donut', 5), ssub('abcdefg', 3, 6))
I mean it's touching _ENV, so I'm not happy... but I got the frontend I wanted.