The use of environments has also changed. For me, this is one of the bigger changes. The functions setfenv and getfenv don’t exist any more, and loadstring is replaced by load.
(I don’t know if @toadkick is still around; if so, you may be interested to know that I’ve adapted cmodule to Lua 5.3. Not sure how well I’ve done it, but it’s functional.)
@LoopSpace - does this affect that neat program for running multiple programs in different tabs? If so, I’d like to use it to fix a number of tutorial demos thar are going to break.
Yes, that would work, though you’d probably want local arg = {...}
You could also use select instead (more efficient if you only want access to a specific argument)
function foo(...)
local x = select(1, ...)
print( x )
end
Here’s the manual entry for select
select (index, ···)
If index is a number, returns all arguments after argument number index; a negative number indexes from the end (-1 is the last argument). Otherwise, index must be the string "#", and select returns the total number of extra arguments it received.
function setup()
useArg(1,3,5,7,9)
print()
useSelect(2,4,6,8,0)
end
function useArg(...)
arg={...}
print("size of arg ",#arg)
for z=1,#arg do
print("values of arg ",arg[z])
end
end
function useSelect(...)
a=select("#",...)
print("size of ... ",a)
a=select(2,...)
print("value of 2nd pos ",a)
a,b=select(3,...)
print("values at pos 3 and 4 ",a,b)
end
@Ignatz Yes, I believe it does since those used setfenv. I think it is possible to emulate setfenv using the debug library, or if we make the invocation just a little more detailed. I’ll need to dig up the code and examine it.
@Ignatz just found it. The key question is whether you would sanction the use of the debug library or not. If not, then I think that the invocation has to be a little more wordy. Something like:
@Simeon sorry to sound obsessed but does this update include sockets, as they are included in Lua 5.3? The answer is probably no, just thought I’d ask anyways