Lua 5.2, almost here

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
ishkabible
Party member
Posts: 241
Joined: Sat Oct 23, 2010 7:34 pm
Location: Kansas USA

Lua 5.2, almost here

Post by ishkabible »

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?!
User avatar
Ensayia
Party member
Posts: 399
Joined: Sat Jun 12, 2010 7:57 pm

Re: Lua 5.2, almost here

Post by Ensayia »

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.
User avatar
TechnoCat
Inner party member
Posts: 1612
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: Lua 5.2, almost here

Post by TechnoCat »

"new lexical scheme for globals"
I don't like the sound of that.
User avatar
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

Post by Taehl »

"new library for bitwise operations"
Woohoo! :D
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+.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Lua 5.2, almost here

Post by Jasoco »

TechnoCat wrote:"new lexical scheme for globals"
I don't like the sound of that.
What does it mean?
User avatar
Xgoff
Party member
Posts: 211
Joined: Fri Nov 19, 2010 4:20 am

Re: Lua 5.2, almost here

Post by Xgoff »

Jasoco wrote:
TechnoCat wrote:"new lexical scheme for globals"
I don't like the sound of that.
What does it mean?
a function environment is now an upvalue called _ENV rather than some hidden value you use getfenv/setfenv for

... 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)
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Lua 5.2, almost here

Post by kikito »

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:
  • 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.
Most of the other changes are C-related, or not very interesting to me.

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.
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: Lua 5.2, almost here

Post by miko »

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?!
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.

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
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Lua 5.2, almost here

Post by vrld »

ishkabible wrote:something i don't like: in Lua 5.2, the goto statement was added...bleh, why?!
Goto has at least the use case as break/continue statement (Luas break only allows breaking out of the inner loop):

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()
The Lua 5.1 equivalent is hackish and ugly in comparison:

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()
It could also be useful for cleanup after errors, as often used in the Linux kernel:

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
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
slime
Solid Snayke
Posts: 3170
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Lua 5.2, almost here

Post by slime »

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)
ipairs was un-deprecated/un-removed several months ago, I think.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 9 guests