lua-users home
lua-l archive

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


> Sounds like you could apply the changes you mention with a
> few #defines/#ifdefs.

There are some problems with #ifdefs: First, as Kernighan and Pike said 
(PoP page 201), "[conditional compilation] is almost impossible to test". 
Each #ifdef creates multiple versions of a program. It is hard to test, 
document, and mantain all of them. Second, there would be multiple versions 
of the language (for instance, "a=2.5" could be invalid in some "official" 
versions of Lua). Third, there is the problem with the API. If we use some 
kind of conditional compilation, like 

  Number lua_getnumber (lua_State *L, lua_Object obj);

with -DNumber=? somewhere, you may have a hard time to make sure that
the lua library and your application are compiled with the same definition.

Another option would be to use a typedef in lua.h, something like

  typedef double lua_Number;

  lua_Number ...

We do not like this, because currently a lot of libraries define their own 
set of basic types, and then when you have to declare a variable you never 
know whether you should write "long", "size_t", "CORBA::Long", etc. We do
not want do add another name to these lists.

For us, it is much easier to write a technical note ;-) and to keep Lua
simple, so that it is easy to make the changes you want.

-- Roberto