lua-users home
lua-l archive

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


It was thus said that the Great Daurnimator once stated:
> On 30 September 2015 at 14:01, William Ahern <william@25thandclement.com> wrote:
> > I've never encountered naming conflicts when using the registry.
> 
> I haven't seen one in practice **yet** but I do think about it.
> 
> I like the idea of matching C typedefs to metatable keys (as used by
> luaL_newmetatable, luaL_checkudata, etc).
> The hope actually *being* that other modules might use it too.
> This way another person may create their own sigset_t containing
> userdata, but can still use my functions.

  Hmm ... interesting.  But it's predicated on similar usage to fully work.
Yours [1] and mine [2] take different approaches to the implementation.  You
have explicit functions to add and remove sets, whereas I took a more
value-meta-table approach to it.

  Yours:

	x = sigset.fill()
	sigset.del(x,SIGSEGV)
	sigset.del(x,SIGILL)
	
	if sigset.ismember(x,SIGWINCH) then ... end

  Mine:

	-- signal.set(true) returns a full set, any addtional signals listed
	-- will remove those signals from the list.
	--
	-- signal.set(false) returns an empty set, any addtional signals
	-- listed will add those signals to the list.

	x = signal.set(true,'segfault','illegal')

	if x['windowchange'] then ... end

> I'm not yet sure if this idea is brilliant or stupid...

  -spc (Yeah, I'm not sure yet either)

[1]	https://github.com/daurnimator/lua-spawn/blob/master/spawn/sigset.c

[2]	https://github.com/spc476/lua-conmanorg/blob/master/src/signal.c#L1503