lua-users home
lua-l archive

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


Soon (2 weeks?) we will release Lua 4.1 alpha. This will be a truly alpha
version. There are several issues that we still want to address, but that
we will wait a while for any decision.  There are also some changes that
are tentative, and we are not sure whether we will keep them.

Here we will briefly describe what is new in 4.1,
starting with what is incompatible with 4.0.

* the main incompatiblity with 4.0 regards userdata. Until Lua 4.0, 
lua_pushusertag used a hash scheme so that equal pointers were coalesced 
into the same udata. That sometimes led to some complex situations, and 
even to inconsistencies (as E.T. pointed out some time ago). So, Lua 4.1 
will not have this coalesce feature. Each "lua_pushusertag" will create a 
new udata, and that is all. This is much simpler to explain and to 
implement, and it is not difficult to implement the old behavior outside 
Lua for those that need it (mainly you keep a table with your udata, and 
you do the hash when/if you need). To avoid unpleasant surprises, 
lua_pushusertag will be renamed. 

* {f()} will create a table will all values returned by f().

* (f()) will "adjust" the call to a single result.

* the option *w in 'read' will be deprecated. (Its definition of "word"
was quite arbitrary, and more often than not it was not what we needed.)
On the other hand, there will be an option to read until a given fixed
delimiter string, with readline being a particular case (read until \n).
(BTW, readline will accept \0 ;-)

* 'global' and 'in' will be reserved words. (We intend to implement some
form of global declarations in 4.1 beta.)



The other changes do not create any incompatibilities (we hope):

* support for external co-routines and multithreads, as already seen
in 4.1 work.

* weak tables - a weak table is a table whose keys or values are
weak references. This is a generalisation of the old lua_ref(0) mechanism
(which is now implemented using weak tables).

* names for tags - new tags (or new types) can have names, just like the
primitive types. All functions in Lua that accept tags (settagmethod,
settag, etc) will also accept the type name instead of the tag.

* secure binary code: Lua now checks precompiled code before running it.
(And dostring accepts binary code.)

* flexible syntax for function and table expressions. Lua now accepts things
like "(write or print)(x)". (We are still unsure about that, because of
the ambiguity in the grammar:  "a = x        (foo)(1)".)

* new functions- lua_load*: similar to lua_do*, but do not run the
code. Roughly, dofile(f) is equivalent do loadfile(f)() (it is not
exactly the same because of error treatment).

*new function- require: already discussed in the list.
*new function- unpack: already discussed in the list.
*new function- tmpfile.
*new function- time/date, with better support for dates and times.


For 4.1 beta, we are already thinking about global declarations and a 
boolean type, but that is for beta (the only question for alpha is whether
we should put "true" and "false" as reserved words??). 

-- Roberto