lua-users home
lua-l archive

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


On Fri, Feb 17, 2012 at 2:25 AM, ernie <elukie@comcast.net> wrote:
> What is the reason for this on line 148?
>
>    local tbuff  -- <=======
>    function tbuff (t,buff,k)
>        ...
>    end

tbuff is a recursive local function, so the symbol must be declared
before the definition. It helps to remember that 'local function f' is
short for 'local f = function' - so any reference to f in that
_anonymous_ function doesn't find the local because it's not defined
yet.

local tbuff
tbuff = function (t,buff,k)
  .-- refer to local tbuff!
   ...
end

steve d.