[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Clean Lua
- From: steve donovan <steve.j.donovan@...>
- Date: Sat, 19 Nov 2011 10:21:43 +0200
On Fri, Nov 18, 2011 at 8:29 PM, Roberto Ierusalimschy
> Moreover, keep in mind that for Lua compiled with LUA_COMPAT_ALL on,
> most of these differences vanish. (LUA_COMPAT_ALL is on in the default
This is an important point; in particular, module() is going to be
available for a long time.
Old Lua 5.0-isms like local 'arg' are easy to fix and LuaJIT has been
useful in this respect.
There are some gotchas, for instance the return type of os.execute
changes. So my preferred approach has been to write compatibility
routines, and so far I've really had no problems writing Lua that
works with both versions.
In Penlight, the 5.1/5.2 compatibility functions are in pl.utils, lines 200-280
There's a version of set/getfenv there as written by Sergey Rozhenko 
The approach to functions like load() and os.execute() that have
changed signatures is to define utils.load and utils.execute that
Separating this code out as lua52-compat.lua would be straightforward.