[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: local function xxx and local yyy= function
- From: "Javier Guerra" <javier@...>
- Date: Tue, 30 Dec 2008 14:17:08 -0500
On Tue, Dec 30, 2008 at 2:14 PM, Linker <linker.m.lin@gmail.com> wrote:
> 1:
> local function n() print(n);n();end
> n()
> infinite loop
> 2:
> local n2=function() print(n2);n2();end
> n2()
> output: nil
> error:attempt to call global 'n2' (a nil value)
> Why?
> --
> Regards,
> Linker Lin
> linker.m.lin@gmail.com
>
from the manual:
2.5.9 - Function Definitions
.....snip...
The statement
local function f () body end
translates to
local f; f = function () body end
not to
local f = function () body end
(This only makes a difference when the body of the function contains
references to f.)
--
Javier