lua-users home
lua-l archive

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


I have spent a couple of days now trying to get my program (a MUD game client) to compile and run with Lua 5.2.

It's taken a while, partly because it took around 2 days to even get it to compile, what with the deprecated functions, removal of LUA_GLOBALSINDEX, luaL_typerror, lua_equal, lua_unref, lua_getref and a few others.

Now the fun begins - trying to get scripts to work. The change to the module behaviour (module being deprecated as well) means that a large number of separate module files no longer work as expected. Formerly you would use:

 module (..., package.seeall)

... and then the "global" functions inside that file were really module-relative, so it was a nice and, well, modular. 

The notes for 5.2 say "Modules are not expected to set global variables anymore, and it is easy to set up a module with regular Lua code.".

Well, expectation or not, the fact is that there are a lot of Lua scripts out there, and major work is likely to be on the horizon for them.

But the big issue is the crashes. Why are there crashes? Because of the DLLs (I am talking Windows here, and yes I know it would be good to avoid Windows if possible).

I have modules that use luasocket, for example. Now the DLLs that ship with that are linked against lua5.1.dll - and since it can find a lua5.1.dll in the path, it loads it. So I now have the main program pulling in lua52.dll and some modules loading in lua5.1.dll - and sooner or later the whole thing crashes, because of the malloc/free problems with clashing DLLs.

So how do we avoid all this? Short of completely upgrading from Lua 5.1 to Lua 5.2 and removing all traces of Lua 5.1 from my system (hardly a practical choice), we need a way of making the Lua 5.2 modules pull in Lua 5.2-compiled DLLs (like luacom, luasocket, and so on). But I'm not sure how this is achieved easily. Right now, for example, luasocket itself pulls in two DLLs, rather confusingly named core.dll and core.dll (in different directories).

Is the solution to rigorously keep DLLs into their own directory paths - even those with the same names (eg. core.dll and core.dll)? Or is it to impose a naming convention on then (eg. luasocket5.2.dll)?

These questions need attention because the "core" Lua 5.2, if released, won't be much use if the wider system cannot easily adapt to it.