Nmap Development mailing list archives
Re: [Lua snippit] print_hex
From: "Patrick Donnelly" <batrick.donnelly () gmail com>
Date: Sun, 7 Sep 2008 23:04:50 -0600
On Sun, Sep 7, 2008 at 7:44 PM, Kris Katterjohn <katterjohn () gmail com> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Patrick Donnelly wrote:That looks fine. I put the "out" local out of the function definition to prevent the string from repeatedly being remade (numbers are constant folded but not strings). I did this mainly to expose people on the list to some good practices (among other things I did), even though it probably won't make a huge difference in a debugging function. If you moved it inside because you didn't want to clutter the surrounding function (the file) with variables, you can surround the print_hex function with do ... end to force scoping.I'm pretty sure Brandon, I and others have brought this up in the past, but it would be awesome to have a "Best Practices" section (short is fine) in the Nmap docs/book somewhere on Lua coding, and any gotchas that could get us who come from many other languages (I think most people here learned Lua solely for NSE... I know I did). I know Brandon recently posted a link on learning Lua from a Perl background, but I've never been much of a Perl guy. And also anything we can do to make things more efficient. I don't know how the Lua interpreter works wrt optimizations or whathaveyou, which is perhaps another good reason for having some docs on this.
I would do this if Fyodor asked me to (it may be out of the scope of his book). I learned most of what I know from reading PiL (Programming in Lua), the Lua Manual, and reading other's code. Cheers, -- -Patrick Donnelly "One of the lessons of history is that nothing is often a good thing to do and always a clever thing to say." -Will Durant _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- [Lua snippit] print_hex Ron (Sep 05)
- Re: [Lua snippit] print_hex Patrick Donnelly (Sep 05)
- Re: [Lua snippit] print_hex Ron (Sep 05)
- Re: [Lua snippit] print_hex Ron (Sep 06)
- Re: [Lua snippit] print_hex Patrick Donnelly (Sep 07)
- Re: [Lua snippit] print_hex Kris Katterjohn (Sep 07)
- Re: [Lua snippit] print_hex Ron (Sep 07)
- Re: [Lua snippit] print_hex Patrick Donnelly (Sep 07)
- Re: [Lua snippit] print_hex Patrick Donnelly (Sep 07)
- Re: [Lua snippit] print_hex Sven Klemm (Sep 08)
- Re: [Lua snippit] print_hex Patrick Donnelly (Sep 07)
- Re: [Lua snippit] print_hex Patrick Donnelly (Sep 05)
- Re: [Lua snippit] print_hex Ron (Sep 07)
- Re: [Lua snippit] print_hex Patrick Donnelly (Sep 07)