Nmap Development mailing list archives

Re: [NSE] firewalk.nse updated


From: Patrick Donnelly <batrick () batbytes com>
Date: Wed, 8 Sep 2010 15:11:14 -0400

On Wed, Sep 8, 2010 at 2:51 PM, Henri Doreau <henri.doreau () gmail com> wrote:
I've also rewritten function "definitions" to use the : "local
function something(arg)" syntax instead of "local something =
function(arg)". I find the former more readable. I can see both used
in nmap scripts, so I assume there is no (or no big) difference
between them.

local function foo(bar) ... end

is syntactic sugar for

local foo; foo = function (bar) ... end

The difference is only noticeable if foo is recursive. If you use:

local foo = function (bar) ... end

then all references to "foo" within the function will not refer to the
local variable foo because it is not in scope yet.

I personally prefer doing "local function foo (bar) ... end" in my
declarations because I find it aesthetically pleasing and always works
as expected when writing recursive functions.

-- 
- Patrick Donnelly
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: