lua-users home
lua-l archive

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


Hello,

I have the following problem with Lua 5.2 build on Windows, MSVC 2008:

----
Lua 5.2.0 (beta)  Copyright (C) 1994-2011 Lua.org, PUC-Rio
local t = {x=10,y=20}
local f1
do local _ENV=t
  function f1()
    return x+y
  end
end
stdin:2: attempt to index local '_ENV' (a nil value)
stack traceback:
         stdin:2: in main chunk
         [C]: in ?

print(f1())
stdin:1: attempt to call global 'f1' (a nil value)
stack traceback:
         stdin:1: in main chunk
         [C]: in ?
----

Why? What am I doing wrong?

I build the Lua interpreter from downloaded lua-5.2.0-beta source files via MSVC 2008; I just created an empty Win console project and I added all source files in it; luac.c must have been excluded from the build as it defines another main() (gives Lua compiler).

If you are familiar with MSVC, you can try the project from http://www.filejumbo.com/Download/A3C039305593C10D - just to check whether you will get the same behaviour.

BTW: I didn't find any Lua-5.2-for-Windows build/installer, so that's why I built Lua.exe myself.

BTW2: The whole discussion on "Struggling with _ENV in Lua 5.2" can be found at
http://forum.luahub.com/index.php?topic=3330.msg7649#msg7649
.

LuP


NB: I sent this mail yesterday, but I probably was not subscribed to this mailing list yet; I apologize if I was and this mail is duplicated so.

--
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038