lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


If it involves a hash lookup, imho, yes. 

Your LUA_USERSTATE is already in there, and works, and
is useful. This was just a suggestion on a more user friendly 
interface to it. 

Regards,
Jim

----- Original Message ----- 
From: "Roberto Ierusalimschy" <rieru@delirius.cs.uiuc.edu>
To: "Multiple recipients of list" <lua-l@tecgraf.puc-rio.br>
Sent: Thursday, January 31, 2002 9:26 AM
Subject: RE: LUA_USERSTATE


| > > So after using this a little and also in lea of the discussion on
| > > libraries - wouldn't a functional interface be a better
| > > solution? One that can accept multiple user contexts referenced
| > > by id? [...]
| > >
| > > id = lua_setuserctx( L, (void*) p );
| > >
| > > p (mycontext*) = lua_getuserctx( L, id );
| > >
| 
| What about this?
| 
|   lua_pushuserdata(L, p);
|   id = lua_ref(L);
|   ...
|   lua_getref(L, id);
|   p = (mycontext*)lua_touserdata(L, -1);
| 
| 
| Too slow?
| 
| -- Roberto
| 
| 
|