OT: 'best' dynamic language

Adrian Perez adrianperez at udc.es
Sun May 4 21:41:20 MSD 2008


On Sat, 26 Apr 2008 19:42:35 +0200
Manlio Perillo <manlio_perillo at libero.it> wrote:

> Adrian Perez ha scritto:
> > [...]
> >
> > I am using Lua in a World Domination™ project I can't talk about
> > (and because it's fun! :-P)
> > 
> 
> May be it a game? ;-).

Not precisely... but it is fun to code :D

> Of course this should be a configurable parameter.
> Using one VM per request means that one can not have persistent 
> connections to a database, as an example.

Well, one can always store persistent values in a hash table in the C
side of the world, and provide a view of it to the Lua side by adding
e.g. an userdata with table metamethds named "persistend" to every VM
state, so one could handle requests the following way:

  if persistent.db_conn ~= nil then
     db_conn = persistent.db_conn
  else
     db_conn = persistent.db_conn = open_database_connection()
  fi

  handle_request(db_conn)


Have a nice day!


-Adrian

-- 
Contrary to popular belief, Unix is user friendly.
It just happens to be selective about who it makes friends with.
                                               -- Dave Parnas





More information about the nginx mailing list