All lua script needs to be updated to be compatible with LUA 5.4.
The new syntax is compatible with LUA 5.2 (tested), but maybe older LUA version are not compatible (not tested)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
...
Linked items
0
Link issues together to show that they're related.
Learn more.
Hello. Thanks for your patch, I'll take a look at it, although I can only check with lua 5.2. I was bemused because of librivox.lua and magnatune.lua that use the simplexml module; indeed these scripts aren't compiled or distributed, but I don't see why excluding them from the update. Also, how does this work for share/lua/http/custom.lua, did you test?
A more troublesome concern is that this seems to break calling scripts. There are third-party out-of-tree scripts out there (for example on https://addons.videolan.org/), some of which might be using the in-tree modules in the old way. Is it possible to remove the no-longer-supported module() calls while maintaining compatibility with any current require that doesn't store its result into a local table? We might want to stay conservative about this.
I did test my patch with LUA 5.2 and LUA 5.4. The scope of the tests was:
Checking that http lua server was working, open a web browser and check that web interface was OK
Tested that the android app named VLCRemote was still working (was broken before this fix)
I did not really understand how share/lua/http/custom.lua was "working", this is the only piece of code that I did not fully understand (How gettext is exported ?). But I did test that with my change that custom.lua was still working: If for example gettext was modified, the modification is taken into account...
I did not test without storing the require result into a local table. But if you say that without this change this does not work (so with a basic require "simplexml", instead of local simplexml = require("simplexml"), I think we are screwed.
I am not an expert (at all) in LUA, but the only solution that I see, is to still call the module function but conditionally on the LUA version
I did not test without storing the require result into a local table. But if you say that without this change this does not work (so with a basic require "simplexml", instead of local simplexml = require("simplexml"), I think we are screwed.
I'm not saying that :) I'm wondering too. I've looked at it briefly, but I'm a bit confused by the results.
I am not an expert (at all) in LUA, but the only solution that I see, is to still call the module function but conditionally on the LUA version
I checked, we do not need to take into account LUA version prior 5.2 (this is way too old, and nobody is going to compile a new VLC version with a very old LUA version)
LUA 5.2 version does the same thing that LUA version 5.3, so I analyze the difference between LUA version 5.2 and 5.4. Here the result:
module must be called if the lua script that require this module only use require "mod" instead of local mod = require("mod")
So for third-party/legacy LUA script, the LUA version must be checked, see my example in the testlua.zip for a factorization if we do not want to duplicate the condition if _VERSION == "Lua 5.1" or _VERSION == "Lua 5.2" or _VERSION == "Lua 5.3" then for every module...
The module returning the object with all "public" functions is fine
For version 5.4:
The only valid way is to return the object with all "public" functions and to use local mod = require("mod")
The way it works is it creates a new table for the module, stores it in the global named by the first argument to module, and sets it as the environment for the chunk, so if you create a global variable, it gets stored in the module table.
So removing the module call goes hand in hand with making all following definitions local. I guess we need a patch that does that and adds your trick at the end for all modules, and a second optional patch to convert all in-tree module requires to the new, cleaner way receiving the module into a local table; I think both changes are really independent from each other.
I am going in vacation, and I am quite busy... So I do not think I will have time to prepare a clean patch soon.
Also there are a lot of difference between the current master branch and the 3.X branch. So I think this require 2 group of patches (one for master and one for 3.X)
What is the current strategy since master has diverged quite a lot of 3.X ?
Lua modules haven't diverged a lot. Ideally, I would fix 5.4 compatibility in master, and then leave 3.0 alone since the change is not really a bugfix and has potential for breaking things. So it's more of a packaging and release management concern.
If I undertand correctly, module() is still supported by lua 5.3, right? When I look at https://www.lua.org/versions.html , it doesn't look like they really maintain older versions; but then it's apparently not a problem to still run VLC with a 5 years old lua version, so I'm not certain that it would be an issue to keep requiring lua 5.3 with VLC 3.0 for a while more.