lua-users home
lua-l archive

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


Some quick notes about Lua 4.0 alpha with LUA_REENTRANT undefined:

a = { sin(1), cos(1) } gives "error: attempt to call a number value" on
fields =
        ObjField{ 0, 0, "", 50 },
        ObjField{ 0, 0, "", 50 }
gives "error: attempt to call a table value" in the 2nd ObjField{}.
In Lua 3.2 at least "a = { sin(1), cos(1) }" works fine.

2) The redefinition of the lua_userinit() as a macro works fine in the
function call but not in the function definition:
1: void lua_userinit() {
2:     lua_iolibopen();
3:     ...
4: }
gives the following messages:
1: warning: formal parameter 1 different from declaration
2: warning: 'argument' : different levels of indirection
2: warning: 'lua_iolibopen' : different types for formal and actual
parameter 1
because "void lua_userinit() {" is replaced with "void
lua_userinit(lua_state) {" and lua_state in declared with the default 
int type.
I solved it using locally the LUA_REENTRANT macro.

3) In src\lua\Readme is written to define "void lua_userinit (void)" 
but it should be "void lua_userinit (lua_State *)".

4) In manual.html is missing the description of the new read(N) feature.

5) In the mailing list file ("Archive") there is an EOF at 2872679th
character and some (MSDOS) editors or some programs which reads Archive 
in text mode stops reading it early.

My wishlist (I already made this changes for myself but I think that 
they could be standard):
6) I use luaM_malloc/free/realloc/new() because they are ready for use
functions with error checking. I would like to have the macro for
LUA_REENTRANT undefined as standard Lua like other auxiliary functions.

7) I think that the Lua 3.2 predefined _PROMPT variable was a good idea 
but in Lua 4.0 it is removed.

8) I prefer to use dynamic allocation memory instead of stack memory for
large variables to reduce the fixed stack size (I can't allocated
dynamically the stack):
a) ldo.c->lua_dofile()
   The variable source (char source[MAXFILENAME]) co
amic memory and freed before calling do_main(L, &z, bin) to 
save 260 bytes of stack for each nested do_main().
b) lua.c->manual_input()
   The variable buffer (char buffer[BUFSIZ]) could be replaced with the
lbuffer.c's functions: this can save stack space or handle a
longer command line.
c) lparser.c->luaY_parser() and body()
   The variables funcstate and new_fs (of type struct FuncState) 
occupies 1028 bytes with my compiler and I prefer to allocate them in 
the dynamic memory.
d) lauxlib.c->luaL_verror()
   The variable buff (char buff[500]) could be easily (and probably 
safely) allocated using dynamic memory.

With this 4 changes I saved abouts 3.25 Kb of stack space (from ~8 Kb to
~4.75 Kb). I don't know exactly how much the executable has grown.

9) I know that this is an old problem. I have added the possibility to 
read the constant numbers with base from 2 to 26 by the compiler 
instead of using the tonumber() function (i.e. 0b10011, 0X1F). I think 
that it's not very difficult to implement and it not increase the 
executable very much. However, it could be used a conditional 
compilation to enable/disable this features.