This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
tesla1889's profile picture

is ComputerCraft ever going to update to Lua 5.2?

Started by tesla1889, 08 February 2013 - 05:42 PM
tesla1889 #1
Posted 08 February 2013 - 06:42 PM
title asks it all

EDIT: i only ask to know if i should plan for compatibility
Cloudy #2
Posted 09 February 2013 - 01:33 AM
Doubt it. Would break a lot of programs.
Kingdaro #3
Posted 09 February 2013 - 07:05 AM
getfenv() and setfenv() were both removed in 5.2. For good reason, I hope.
tesla1889 #4
Posted 09 February 2013 - 12:40 PM
getfenv() and setfenv() were both removed in 5.2. For good reason, I hope.

there are work arounds for both of those involving the added _ENV table. i ask because i often find myself using those and i want compatibility
NeverCast #5
Posted 09 February 2013 - 12:42 PM
ipairs was also removed in 5.2, Though there are alternatives. This would break many programs also.
Kingdaro #6
Posted 09 February 2013 - 12:50 PM
ipairs isn't removed, it's only deprecated.

there are work arounds for both of those involving the added _ENV table. i ask because i often find myself using those and i want compatibility
I tried screwing around with _ENV, but could never fully figure it out. I'll look up a tutorial or something later on.
tesla1889 #7
Posted 09 February 2013 - 12:55 PM
_ENV is the environment table

a workaround for setfenv would be

setfenv = function(fn,env)
if (type(fn) ~= "function") or (type(env) ~= "table") then
error("invalid args")
end
env.main = fn
env.oldenv = _ENV
return function(...)
_ENV = env
local t = {main(...)}
_ENV = oldenv
return unpack(env.t)
end
end
hvenev #8
Posted 20 September 2013 - 04:42 AM
I need lua 5.2 for my scripts.

There is an implementation of {get,set}fenv for lua 5.2. https://github.com/davidm/lua-compat-env
Cranium #9
Posted 20 September 2013 - 09:32 AM
It's not happening. Stop bringing it up.
Lyqyd #10
Posted 20 September 2013 - 01:10 PM
Also, I have no idea where the ipairs being removed/deprecated nonsense came from, since Lua 5.2 adds an __ipairs metamethod.