[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: mathlib
- From: "Claire Lewis" <claire_lewis@...>
- Date: Tue, 8 Apr 2014 23:23:37 +0930
This is the best that can be done currently:
https://github.com/Pogs/lua-snippets/blob/master/table-import.lua
It's handicapped in that it of course can't make locals.
Not sure if I’d call that the ‘best’, but it’s certainly one solution.
I’d probably prefer to use something like :
function import(name)
local mod = require(name)
return function(t)
for k,v in pairs(t) do
t[k] = mod[v]
end
return unpack(t)
end
end
Import locals:
local C,V = import "lpeg" { "C", "V" }
Import globals:
C,V = import "lpeg" { "C", "V" }
Note this modifies the table passed in, but could just as easily return a
new table.
- Claire.
- References:
- Re: mathlib, Roberto Ierusalimschy
- Re: mathlib, Coroutines
- Re: mathlib, Luiz Henrique de Figueiredo
- Re: mathlib, Roberto Ierusalimschy
- Re: mathlib, Christopher Berardi
- Re: mathlib, steve donovan
- Re: mathlib, Christopher Berardi
- Re: mathlib, Sean Conner
- Re: mathlib, Coroutines
- Re: mathlib, Sean Conner
- Re: mathlib, Christopher Berardi
- Re: mathlib, steve donovan
- Re: mathlib, Coroutines