[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] lua-getsize
- From: Sean Conner <sean@...>
- Date: Sat, 27 Nov 2010 19:09:05 -0500
It was thus said that the Great Matthew Wild once stated:
> On 27 November 2010 15:22, Alexander Gladysh <agladysh@gmail.com> wrote:
> > On Sat, Nov 27, 2010 at 16:55, Cosmin Apreutesei
> > <cosmin.apreutesei@gmail.com> wrote:
> >> This is a small C module by Matthew Wild that adds a debug.getsize()
> >> function which returns the size in bytes of a Lua object.
> >
> >> Homepage: http://code.matthewwild.co.uk/lua-getsize/summary
> >
> >> I found it useful so I packaged it and added a small test unit -
> >> tested in win32 and linux64. Grab it while it's hot:
> >> http://code.google.com/p/lua-aux-lib/downloads/list.
> >
> > Thank you for the useful contribution.
> >
> > But why does this module change a standard namespace?
> >
>
> It's a debugging function. it's very implementation-specific. It
> belongs with other debugging functions. It's overkill to make a new
> namespace for a single function.
I don't think so. I've created a few functions [1] that I felt should go
into debug but didn't want to pollute that particular namespace. So I
created the namespace "org.conman" and beneath that, created
"org.conman.debug" as a place for my debug functions to live. That way, I
can either specify the full ... um ... path, to the function, or do
something slick like:
setmetatable(debug,{ __index = org.conman.debug }) --[2]
I also did org.conman.table and org.conman.string, along with a few other
modules I've written [3]. That way, I only have to worry about clashing
with "org.conman" (which is unlikely) and not "debug" or "table" or
"getopt".
-spc (I should probably release these modules at some point ... )
[1] edit(), which edits the source for a given function written in Lua
editf(), which edits the source file a given function is defined in
hexdump(), which gives a hex dump of memory
[2] Cute, but probably dangerous as well. And not something I would do
8-P
[3] org.conman.env:
contains each environment variable, such that
org.conman.env['HOME']
is the path to $HOME
org.conman.unix:
Loads /etc/passwd and /etc/group as tables:
org.conman.unix.users
org.conman.unix.groups
And creates to store paths:
org.conman.unix.paths
usable thus:
print(org.conman.unix.paths['ls'])
org.conman.getopt:
Supports a Unix-like getopt() routine to parse the command
line