lua-users home
lua-l archive

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


2014-08-13 20:00 GMT+02:00 Tim Hill <drtimhill@gmail.com>:
> On Aug 13, 2014, at 4:55 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> [1] Binary chunks can have _ENV parameters, so (a) is possible.
>
>
> Interesting, how do you do that?

$ lua
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> f=function(_ENV) return _ENV,id end
> cf=string.dump(f)
> io.open("f.luac","wb"):write(cf):close()
>
$ lua
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> f=loadfile"f.luac"
> print(_ENV)
table: 0x1f205f0
> return f{id="my_env"}
table: 0x1f440d0    my_env