Nmap Development mailing list archives
Re: [NSE][PATCH] string_ext library
From: Sven Klemm <sven () c3d2 de>
Date: Wed, 01 Oct 2008 12:43:29 +0200
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Patrick, Patrick Donnelly wrote: | Other applications (notably, World of Warcraft) often add to the | string library directly, such as string.strsplit. I recommended in [1] | that the string library be extended with our own library. You are | right this may confuse people new to Lua. I think it is fine for the | most part although people should be cautious extending libraries in | this way because it can easily lead to incompatibilities. But... | | I should add that while this lends a certain elegance to indexing | string functions it will always be slower than just having a local | reference to this extension library and indexing the functions | directly. | | e.g. | | local string_ext = require"string_ext" | | function action(host, port) | print(string_ext.to_hex("abcd")) -- faster | -- vs. | print(("abcd"):to_hex()); -- slower | end | | Beginning a practice where extended string functions are added to a | super class of the standard string library where speed is being | sacrificed will probably bite us in the long run. For this reason and | the confusion of new users, it's probably best to avoid doing this | (sorry Sven for having misled you earlier). Hmm extending string would really make more beautyful code IMO. Do you have any numbers regarding the performance difference? Does that imply that using ("abc"):foo() is also bad for performance since this probably also does a global string lookup instead of using a local copy of the string table. Currently there is already a tohex() function in stdnse.lua which only works for numbers. It's probably best to rename my function to tohex() since this is more in line with the lua function names. Do you think we should put this function into its own module or do you think it should be added to stdnse? Cheers, Sven - -- Sven Klemm http://cthulhu.c3d2.de/~sven/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkjjVFEACgkQevlgTHEIT4YxEACeIY/TPohj4Adv0p/jLJUMCvdV JQwAnRJYI6acekfw5/aeZPpGUsEc2fir =jb4x -----END PGP SIGNATURE----- _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- Re: [NSE][PATCH] string_ext library Sven Klemm (Oct 01)
- Re: [NSE][PATCH] string_ext library Patrick Donnelly (Oct 02)
- Re: [NSE][PATCH] string_ext library Sven Klemm (Oct 03)
- Re: [NSE][PATCH] string_ext library Sven Klemm (Oct 03)
- Re: [NSE][PATCH] string_ext library David Fifield (Oct 03)
- Re: [NSE][PATCH] string_ext library Sven Klemm (Oct 03)
- Re: [NSE][PATCH] string_ext library Sven Klemm (Oct 03)
- Re: [NSE][PATCH] string_ext library Patrick Donnelly (Oct 02)