lua-users home
lua-l archive

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


On Sat, Jul 16, 2011 at 18:02, Tom N Harris <telliamed@whoopdedo.org> wrote:
> But (as is) it needs 5.1 to compile, because of this function.
>
>    -- Evaluate condition with a Lua expression. Substitutions already
> performed.
>    local function cond_eval(cond)
>      local func, err = loadstring("return "..cond)
>      if func then
>        setfenv(func, {}) -- No globals. All unknown identifiers evaluate to
> nil.
>      -- rest of function omitted for brevity
>    end
>
> You need something like this
>
>    function loadin(source, env)
>      if setfenv then
>        local func, err = loadstring(source)
>        if func then
>          setfenv(func, env)
>        end
>        return func, err
>      end
>      return load(source, nil, nil, env)
>    end

So it seems. That would be in dynasm which doesn't seem to run on lua
5.2. Fixed in trunk. Thanks for the report.

-- James