[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Saving a table in file
- From: Doug Rogers <douglua@...>
- Date: Mon, 08 Mar 2010 22:30:00 -0500
Petite Abeille wrote:
If you liked the above, you will positively love the following:
local DB = require( 'DB' )
local aDB = DB( 'sqlite3://localhost/test.db' )
for aContact in aDB( 'select * from contact' ) do
print( aContact.name, aContact.email )
I do indeed find that attractive. But notice how it doesn't use indexing
for function invocation. That's the weird part about the Data module, at
least it is weird for me.
Another inspirational example, a bare bone HTTP server:
local HTTP = require( 'HTTP' )
local TCPServer = require( 'TCPServer' )
local aServer = TCPServer( '127.0.0.1', 1080 )
HTTP[ '/' ] = function() return 'Hello world' end
aServer( HTTP )
All except the HTTP['/'], which I assume sets code to run when a URL
gives just the host name with a '/' after it. I guess I can see that as
a form of indexing, in a way. And in that way maybe I can get my brain
to see Data['file.lua'] = t to be some sort of indexing. The latter will
take a bit longer!
I would blame Rici Lake's FuncTable for the initial inspiration:
Another fun piece of Lua application that I have visited before. I think
the wiki page should be /Functables (without a capital T).
For your viewing delight, here is the result of all that handy work:
Yes, I've played around with Nanoki. I like it. It was quite simple to
set up my own little http playpen. That was some years ago and I haven't
had the need since. That might be changing here in the future. The thing
I loved about Nanoki was its tiny size and its understandability.