lua-users home
lua-l archive

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


On Thu, Feb 11, 2016 at 8:44 PM, Sean Conner <sean@conman.org> wrote:
> It was thus said that the Great Peter Aronoff once stated:
>>
>> I do essentially the same thing, and I think it is (relatively) common.
>> I first got the idea from a blog post[1] and I wrote up how I do it in
>> C modules as well[2]. (My method is just a variant of yours.)
>>
>> [1]: http://kiki.to/blog/2014/03/31/rule-2-return-a-local-table/
>> [2]: http://ithaca.arpinum.org/2014/04/20/lua-c-modules.html
>
>   I'm really replying to [2].  There, you wrote:
>
>> You certainly wouldn’t write a C module only to export constants or
>> strings to Lua.
>
>   Well, yes, I would.  In fact, I did.  Twice.  There's org.conman.env [1],
> which is a module that just creates a table of all the environment
> variables, no functions whatsoever.  Then there's org.conman.errno [2] which
> is nothing more than a table of system defined errors (like EDOMAIN, ERANGE
> etc.).

Constants like EDOMAIN, ERANGE are not available from Lua so doing it
in C is the only option. Version and copyright strings can be
hard-coded in Lua as well as in C.

>
>   -spc (As I learned, never say never)
>
> [1]     https://github.com/spc476/lua-conmanorg/blob/master/src/env.c
>
> [2]     https://github.com/spc476/lua-conmanorg/blob/master/src/errno.c
>



-- 


Best regards,
Boris Nagaev