lua-users home
lua-l archive

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



Reuben Thomas wrote:
> 
> > system without baselib, you might not want to have even the _VERSION
> > global defined. (Perhaps you want to use it for some other purpose.)
> 
> In that case, you can redefine it. It's certainly useful to know what
> _VERSION of Lua you're running, regardless of the libraries.

from lua.h:


#define LUA_VERSION	"Lua 4.1 (alpha)"
#define LUA_COPYRIGHT	"Copyright (C) 1994-2001 TeCGraf, PUC-Rio"
#define LUA_AUTHORS 	"W. Celes, R. Ierusalimschy & L. H. de Figueiredo"

from lbaselib.c:

  lua_pushliteral(L, l_s(LUA_VERSION));
  lua_setglobal(L, l_s("_VERSION"));

So if you're not running the libraries, include the above two lines in
your executable, just after creating the lua_State.

I stick with my original claim that a vanilla environment should be as
clean as possible. If you're setting up a vanilla environment, you
probably know what you're doing... I would probably have defined
_VERSION to be the version string for my application in that case,
anyway, so if I wanted it, I would change it to:

  lua_pushliteral(L, l_s(LUA_VERSION));
  lua_setglobal(L, l_s("_LUA_VERSION"));

l_s is defined in lua.h to be the identity macro, by the way.

In the particular case you're interested in (tinsert), what you're
really interested in is the version of baselib, which is not necessarily
the same as the version of Lua (although I think it always has been, it
would certainly be possible to do a new release of the libraries without
releasing a new Lua, since they just use the published API.) I think it
is appropriate for libraries to identify their versions in a documented
fashion. This is not say that I don't think it's useful for Lua to
identify its version, but it does so in lua.h, which you can do with
what you choose. :-)