Lua Five Features

lua-users home
wiki

Difference (from prior author revision) (major diff, minor diff)

Changed: 1,2c1
TODO: Could someone update this for Lua 5.0 final please?
----
=== Changes from version 4.0 to 5.0 ===

Changed: 4,73c3
From the mailinglist:

As several people have suggested, the next version will be 5.0. We are
still planning to realease it (at least an alpha version) by May, but we
are not sure we will be able to do that. Anyway, we are trying to fix
some decisions. So, following is a list of the main differences from
lua4.1w4 to Lua 5.0. Most of them have been discussed in the list
already.

- "generic for": will have an implicit state, so that for several common
uses you don't need a new closure for each `for'.

- co-routines: basically as it is, but we will try to allow for `yield's
inside linehooks.

- metatables: as it is now, but the keys will be prefixed with '__'
(e.g. __gettable, __settable, etc.) The main idea is to facilitate
finding parts of the code that deal with metatables.

- error handling: we will probably change functions related to error
handling (dostring/dofile, call, etc.). We will have a proposal soon.

- standard libraries: standard libraries now use "namespaces". So,
strfind now is str.find, sin is math.sin, fileopen is io.open. Some
basic functions (type, assert, error, etc.) are still global. We also
changed the io library; e.g. files act as objects (f = io.open(...);
f:read(...); f:write(...)).

- declaration of globals: we introduced global declarations:

global a,b,c
global a,b,c in T
global in T -- change the default

So, "global in nil" forces declarations for every variable;
"global in {}" puts all undeclared variables into a private table;
"global sin, cos in math" allows the unqualified use of the
names "sin" and "cos".

- we introduced a "lightweight userdata", which is a value and not an
object.

- require: the path now specifies "templates", instead of directories.
For instance, require "A" with path "./?.lua;./?.lc;/usr/local/?/init.lua"
will look for "./A.lua", "./A.lc", and "/usr/local/A/init.lua".


What is still missing?

- "partial orders": the bug in comparisons with NaN must be solved. That
implies in not reducing other comparisons to "lt", and so probably the
solution will also change the "lt" tag method.

- the declaration "global in nil" forces the declaration of *all* names.
So, even basic functions like "type" and "error" should be declared. It
would be good to have some scheme to "pre-declare" some identifiers...

-- Roberto


i just wanted to comment that this looks VERY promising...
anyone still missing something? please add your comments. --PeterPrade

Some comments about dofile(): I don't know if it will be possible in Lua 5.0, but in Lua 4.0 I had problems whenever I wanted to write modules in different directories. Imagine each directory had an "init.lua" which is responsible for loading all .lua files. When a module in a directory up calls dofile("<subsystem>/init.lua"), the dofiles in init.lua are relative to an unknown directory, thus for init.lua to work properly, we should put the full path on init.lua. It would be better if dofile was relative to the current executing .lua directory. --LuizCarlosSilveira

In other cases one may not want such behavior. Consider making your own wrapper for dofile to handle this.

----

=== Changes from version 4.0 to 5.0 (beta) (From lua-5.0-beta\HISTORY) ===
(from HISTORY file in distribution)

Removed: 76,94d5
* lexical scoping.
* Lua coroutines.
* standard libraries now packaged in tables.
* tags replaced by metatables and tag methods replaced by metamethods, stored in metatables.
* proper tail calls.
* each function can have its own global table, which can be shared.
* new __newindex metamethod, called when we insert a new key into a table.
* new block comments: --[[ ... ]].
* new generic for.
* new weak tables.
* new boolean type.
* new syntax "local function".
* (f()) returns the first value returned by f.
* {f()} fills a table with all values returned by f.
* \n ignored in [[\n .
* fixed and-or priorities.
* more general syntax for function definition (e.g. function a.x.y:f()...end).
* more general syntax for function calls (e.g. (print or write)(9)).
* new functions (time/date, tmpfile, unpack, require, load*, etc.).

Changed: 96,101c7,25
== API ==
* chunks are loaded by using lua_load; new luaL_loadfile and luaL_loadbuffer.
* introduced lightweight userdata, a simple "void*" without a metatable.
* new error handling protocol: the core no longer prints error messages; all errors are reported to the caller on the stack.
* new lua_atpanic for host cleanup.
* new, signal-safe, hook scheme.
*lexical scoping.
*Lua coroutines.
*standard libraries now packaged in tables.
*tags replaced by metatables and tag methods replaced by metamethods, stored in metatables.
*proper tail calls.
*each function can have its own global table, which can be shared.
*new __newindex metamethod, called when we insert a new key into a table.
*new block comments: --[[ ... ]].
*new generic for.
*new weak tables.
*new boolean type.
*new syntax "local function".
*(f()) returns the first value returned by f.
*{f()} fills a table with all values returned by f.
*\n ignored in [[\n .
*fixed and-or priorities.
*more general syntax for function definition (e.g. function a.x.y:f()...end).
*more general syntax for function calls (e.g. (print or write)(9)).
*new functions (time/date, tmpfile, unpack, require, load*, etc.).

Changed: 103c27
== Implementation ==
== API ==

Changed: 105,123c29,33
* new license: MIT.
* new, faster, register-based virtual machine.
* support for external multithreading and coroutines.
* new and consistent error message format.
* the core no longer needs "stdio.h" for anything (except for a single use of sprintf to convert numbers to strings).
* lua.c now runs the environment variable LUA_INIT, if present. It can be "@filename", to run a file, or the chunk itself.
* support to user extensions in lua.c. sample implementations given for dynamic loading and command line editing.
* safe garbage-collector metamethods.
* precompiled bytecodes checked for integrity (secure binary dostring).
* strings are fully aligned.
* position capture in string.find.
* read('*l') can read lines with embedded zeros.
* coffee-brewing capabilities

- new, faster, register-based virtual machine?
Can so give an estimation of improvement ?
I think it isn't worth to change things for 10 or 20%

-- P.Lefevre
*chunks are loaded by using lua_load; new luaL_loadfile and luaL_loadbuffer.
*introduced lightweight userdata, a simple "void*" without a metatable.
*new error handling protocol: the core no longer prints error messages; all errors are reported to the caller on the stack.
*new lua_atpanic for host cleanup.
*new, signal-safe, hook scheme.

Changed: 125c35
----
== Implementation ==

Changed: 127c37,49
By "proper tail calls" does that mean Lua does full tailcall elimination, or is it restricted to the recursion case?
*new license: MIT.
*new, faster, register-based virtual machine.
*support for external multithreading and coroutines.
*new and consistent error message format.
*the core no longer needs "stdio.h" for anything (except for a single use of sprintf to convert numbers to strings).
*lua.c now runs the environment variable LUA_INIT, if present. It can be "@filename", to run a file, or the chunk itself.
*support for user extensions in lua.c. Sample implementation given for command line editing.
*new dynamic loading library, active by default on several platforms.
*safe garbage-collector metamethods.
*precompiled bytecodes checked for integrity (secure binary dostring).
*strings are fully aligned.
*position capture in string.find.
*read('*l') can read lines with embedded zeros.

Removed: 129d50
The former.

Changes from version 4.0 to 5.0

(from HISTORY file in distribution)

Language

API

Implementation


LuaFiveAlphaToBeta
RecentChanges · preferences
edit · history
Last edited January 30, 2004 7:47 am GMT (diff)