Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Lua question - Gideros Forum

Lua question

GregBUGGregBUG Guru
edited January 2012 in General questions
hey guys!

what are differences from declaring function in lua between this two:

1) local dummy = function(x,y,z)

2) local function dummy(x,y,z)

are only aesthetic?

thanks.
TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
www.tntengine.com

Comments

  • atilimatilim Maintainer
    Afaik, there is a small difference when you're using recursion: http://www.lua.org/pil/6.2.html Otherwise, there is no difference between these two.
  • MikeHartMikeHart Guru
    edited January 2012
    Local functions are called faster. Defining these two ways, there is no difference. But I am sure you already had scope problems, that you needed to call function, that was defined BELOW the calling line. To get around this you do this:
    local foo1 
     
    function foo2()
        foo1()
    end
     
    foo1 = function()
      --.....
    end
    The document Atilim has linked to explains this under "forward declarations".
  • oh thanks! guys!!!

    my knowledge of "lua" needs to grow up fast!
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
Sign In or Register to comment.