lua-users home
lua-l archive

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


Hi

I've run several times into weird bugs when working on different projects using
different libs and after spending quite some amount of time I realize at some
point that the libraries I've been using were compiled for slightly different
lua versions and just run fine after fixing that issue. It still needs me often
quite some time to track that down because the produced errors can be quite
subtle (crashes, error messages for codelines that are valid, values that
cannot be found in certain tables etc.).

Since there are a lot of libraries out there that can be downloaded and don't
need to be compiled (at least on win32 systems as these downloadable files come
often with compiled binaries), wouldn't it probably useful to enforce some
version / compatibility test before a library is loaded, throwing an error if
it's incompatible?

A DLL loading function could make simply a test like

lua_checkversion(L,LUA_VERSION);

just right away when initializing. LUA_VERSION is just a value that is compiled
into the lib and comes from the lua version the lib has been linked against
where the checkversion function is simply looking up a value in the lua vm
struct and checks if the lua vm is suitable for the library - and if not, it
throws an appropriate error message before things are getting complicated...

Just an idea to prevent searching for bugs after making a release that makes the
VMs incompatible for previous versions... Or have I overlooked until now an
already given function in the lua api?

Eike