lua-users home
lua-l archive

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


A work version of an improved lua.c is now available at
	http://www.tecgraf.puc-rio.br/lua/work/lua.c

The main improvement of this work version of lua.c is that it automatically
identifies incomplete statements and so there is no need for ending lines
with \ . Just write naturally. For example:

 % a.out
 Lua 4.1 (beta)  Copyright (C) 1994-2001 TeCGraf, PUC-Rio
 > for i=1,3 do
 >> print(i)
 >> end
 1
 2
 3
 >

Note the continuation prompt >>. It can be changed by setting _PROMPT2.

Another improvement is that there is support for GNU readline: just compile
lua.c with -DUSE_READLINE. GNU readline gives line editing and history.

Finally, lua.c can be used as a calculator, by starting lines with = as in:

 > = cos(30), tan(30), print
 0.8660254037844387      0.5773502691896257      function: 0x8068030

This feature was already present in 4.1 (work), but may have gone unnoticed.

This work version of lua.c compiles ok under 4.1 (work) available in the same
directory above and also under 4.1 (alpha), if you use l_getargs from
4.1 (alpha). It's a simple one-line change:
 from
	l_char **argv = (l_char **)lua_touserdata(l, lua_upvalueindex(1));
 to
	l_char **argv = (l_char **)lua_touserdata(l, -1);

Enjoy!
--lhf