Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm going to be "that guy":

  -- These are the same:
  -- ...snip...
  local function g(x) return math.sin(x) end
  local g = function (x) return math.sin(x) end
According to the Lua Reference Manual [1], this example isn't correct. Rather, this is the correct translation:

  local function g(x) return math.sin(x) end
  local g; g = function (x) return math.sin(x) end
From the manual: "This only makes a difference when the body of the function contains references to f."

[1] http://www.lua.org/manual/5.2/manual.html#3.4.10



What this means in practice:

  > local g=function() print(type(g)) end g()
  nil
  > local function g() print(type(g)) end g()
  function


You're right; I fixed that part.


you also miss a couple of "local newObj" in constructors.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: