so Lua 5.2 is almost here and it will hopefully "change the way the way you love" what are you looking forward too in 5.2? what do not like?
something i don't like: in Lua 5.2, the goto statement was added...bleh, why?!
Lua 5.2, almost here
- ishkabible
- Party member
- Posts: 241
- Joined: Sat Oct 23, 2010 7:34 pm
- Location: Kansas USA
Re: Lua 5.2, almost here
http://www.lua.org/work/doc/
A little over halfway down the page is the complete change list. There's a note about Lua getting a new bitops library. I have not done much with them but hear that Lua needs a little extra support to do them right, Hopefully this is good news. The rest is sort of over my head.
A little over halfway down the page is the complete change list. There's a note about Lua getting a new bitops library. I have not done much with them but hear that Lua needs a little extra support to do them right, Hopefully this is good news. The rest is sort of over my head.
- TechnoCat
- Inner party member
- Posts: 1612
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Lua 5.2, almost here
"new lexical scheme for globals"
I don't like the sound of that.
I don't like the sound of that.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Lua 5.2, almost here
"new library for bitwise operations"
Woohoo!
Woohoo!
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Lua 5.2, almost here
What does it mean?TechnoCat wrote:"new lexical scheme for globals"
I don't like the sound of that.
Re: Lua 5.2, almost here
a function environment is now an upvalue called _ENV rather than some hidden value you use getfenv/setfenv forJasoco wrote:What does it mean?TechnoCat wrote:"new lexical scheme for globals"
I don't like the sound of that.
... of course some people aren't very happy about this since the latter two functions are now deprecated and therefore breaks existing sandboxes (and unlike setfenv you can't just change some function's environment given a stack offset or the function reference anymore)
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Lua 5.2, almost here
The best page I could find explaining the changes is this one: http://www.corsix.org/content/look-lua-52-work3
The "global memory change" can be explained like this: if you don't use setfenv or getfenv, you don't need to worry about it - But you might want to check how you use _G, and consider using _ENV instead.
Longer explanation: there is a new guy in town called _ENV, and he's stronger than the previous _G global variable (which still exists, but it can be eliminated via _ENV). Also, setfenv and getfenv will dissapear. You manually set _ENV to whatever you want before creating a function. setfenv was sometimes used when loading and executing code from a file or string (for sandboxes). Since it's deprecated now, they created a function just for that, called loadIn.
The other important changes for me are:
I would have thought that module was being deprecated, but I could not find a reliable source confirming that. Nevertheless, everyone is running away from it nowadays.
The "global memory change" can be explained like this: if you don't use setfenv or getfenv, you don't need to worry about it - But you might want to check how you use _G, and consider using _ENV instead.
Longer explanation: there is a new guy in town called _ENV, and he's stronger than the previous _G global variable (which still exists, but it can be eliminated via _ENV). Also, setfenv and getfenv will dissapear. You manually set _ENV to whatever you want before creating a function. setfenv was sometimes used when loading and executing code from a file or string (for sandboxes). Since it's deprecated now, they created a function just for that, called loadIn.
The other important changes for me are:
- The bit lib
- ipairs is deprecated in the current version (which is ok, I guess, since the numeric for is equivalent and faster. In some rare occasions someone might need to implement their own ipairs though)
- unpack has been put inside table: table.unpack . There's also a table.pack function, not exactly inverse, but nearly.
- The debug lib is not loaded by default
- Empty statements (a semicolon) are allowed - useful for machine-generated code.
- Strings have a "ignore all the blank characters until the next non-black thing" escape char. This will be very useful for creating 2d maps in the code, while keeping proper indentation.
I would have thought that module was being deprecated, but I could not find a reliable source confirming that. Nevertheless, everyone is running away from it nowadays.
When I write def I mean function.
Re: Lua 5.2, almost here
The most important (in positive sense) change for me is the dissappearance of module(), and the way I create modules (returning a table value, not messing with globals), which is still compatible with 5.1.ishkabible wrote:so Lua 5.2 is almost here and it will hopefully "change the way the way you love" what are you looking forward too in 5.2? what do not like?
something i don't like: in Lua 5.2, the goto statement was added...bleh, why?!
Bit library is nice, but since I use love with luajit, I already have it. For me, there is no rush to upgrade to 5.2.
As of goto... I will never use it anyway. I still remember my first programs in Basic with lots of goto's.
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
Re: Lua 5.2, almost here
Goto has at least the use case as break/continue statement (Luas break only allows breaking out of the inner loop):ishkabible wrote:something i don't like: in Lua 5.2, the goto statement was added...bleh, why?!
Code: Select all
while some_condition do
while some_other_condition do
if break_condition then
goto done
elseif inner_break_condition then
goto continue
end
end
::continue::
stuff()
end
::done::
more_code()
Code: Select all
(function()
while some_condition do
if "break" == (function()
while some_other_condition do
if break_condition then
return "break"
elseif inner_break_condition then
return
end
end
end)() then return end
stuff()
end
end)()
more_code()
Code: Select all
function foo()
if not one() then goto on_error
elseif not two() then goto cleanup_one
elseif not three() then goto cleanup_two
else return true end
::cleanup_two::
undo_two()
::cleanup_one::
undo_two()
::on_error::
return false
end
What I'm exited about:
- finalizers for tables
- tables honor the __len metamethod
- slime
- Solid Snayke
- Posts: 3170
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Lua 5.2, almost here
ipairs was un-deprecated/un-removed several months ago, I think.kikito wrote:
- ipairs is deprecated in the current version (which is ok, I guess, since the numeric for is equivalent and faster. In some rare occasions someone might need to implement their own ipairs though)
Who is online
Users browsing this forum: No registered users and 8 guests