[luci] Lua 5.2/5.3 (was: luci Lua modules)

Stephan Hennig sh-list at posteo.net
Sat Jan 16 15:02:29 CET 2016


Am 15.01.2016 um 20:33 schrieb Jo-Philipp Wich:	

>> I've read that OpenWrt's LuCI web interface will be replaced by a 
>> non-Lua-based one in the future (LuCI2). What does that mean for 
>> the Lua scripting language in OpenWrt?
> 
> It will probably stay around but not sure if someone will invest work
> in porting it beyond version 5.1x - it is unfortunately that the Lua 
> authors broke compatibility with later releases.

Are changes in language features a show stopper?  Or is it the LNUM
patch?  Is the latter still needed for Lua 5.3 on OpenWrt?

Here are some thoughts on issues porting Lua code to new Lua versions.
(Sorry if this has been discussed before.  The mail archive is not very
accessible.)

i) The removal of the 'module' keyword probably requires quite a number
of code lines to adapt, but otherwise this should not be too difficult.

ii) There are some other uses of deprecated/moved/removed keywords in
luci that should be equally easy to fix, e.g., unpack has been moved to
the table library.

iii) Changes in environment handling may be a more tough one, depending
on how LuCI (or other OpenWrt code) makes use of setfenv/getfenv.  This
is an area that I, personally, would not like to put my hands on.

iv) Then there are some changes to Lua 5.2 and 5.3 like strings can have
embedded zeros and print(<float>) always adds a trailing '.0', which can
lead to subtle errors when parsing strings.  May not be easy to catch in
advance, but problems are not to be expected in "regular code".

v) (optionally) Code can use built-in bitwise operators instead of
falling back to external libraries (nixio.bit).

Would patches adapting existing Lua code to the Lua 5.2/5.3 feature
level be welcome?

Best regards,
Stephan Hennig

PS: Just a tiny thing I'd prefer a newer Lua version (regardless the
obvious features), with Lua 5.2, file:close() of an io.popen()ed file
returns the shell exit code, which it doesn't with Lua 5.1.


More information about the luci mailing list