lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


(...) Remember that this syntax:

local function g() end

is equivalent to

local g = function() end

Just a small correction:

local function g() end ==> local g; g = function() end

The difference?

1  local g =
2  function( x )
3      if x <= 1 then
4          return x
5      else
6          return x * g( x - 1 )
7      end
8  end
9
10 g(10)
editor:6: attempt to call global `g' (a nil value)


http://www.lua.org/manual/5.0/manual.html#2.5.8
"
The statement

       local function f () ... end

translates to

       local f; f = function () ... end
"

--rb