[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua binding: How to implement C enum
- From: Sean Conner <sean@...>
- Date: Fri, 16 Dec 2011 20:14:25 -0500
It was thus said that the Great Sam Roberts once stated:
>
> For what its worth, I've seen APIs that pass strings or tables of
> strings, and I've seen apis that define names for numbers,
> and pass numbers in, and I've seen keyword apis that use tables where
> strings keys are true or false, but I've NEVER seen a lua API that has
> strings concatenated together to represent flags... I think its weird.
> YMMV.
I had to do the concatenated strings at work, to match the use of an
existing tool. Granted, the flags are all single characters so it's not
that bad:
rec = lnp.record(key,"xcil")
And it's only used for input. I also support a table approach as well, for
both input and output:
rec = lnp.record(key, { 'company' , 'capable' , 'min' , 'licensed' })
And this in a load-testing tool.
-spc (Lua, even though we can't use LuaJIT [1], is fast enough)
[1] Because this particular load test *has* to run on Solaris, and
LuaJIT does not support the SPARC architecture.