[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT FFI: How to load 2 libraries into 2 ffi namespace and avoid conflicts?
- From: Johnson Lin <arch.jslin@...>
- Date: Sat, 27 Aug 2011 13:57:52 +0800
Hello Mike:
On Fri, Aug 26, 2011 at 5:34 PM, Mike Pall <mikelu-1108@mike.de> wrote:
> The FFI simply implements C semantics and C has only a single,
> unified namespace. What you're trying to do wouldn't work in C
> either.
>
> Also, I'm not sure that your quest to save a few keystrokes is
> really justified. Code is more often read than written. Sooner or
> later someone will stumble upon some Init() and won't find it in
> the docs, without mentally replacing it with LibA_Init().
>
IMHO it's not just trying to save a few keystrokes. There's just
something not consistent to me because, yeah, I know C only have one
unified namespace, so we only have one ffi.cdef() to declare them,
however we have to load additional C libraries into different
namespaces. (local LibA = ffi.load(path_to_LibA))
I was thinking there're reasons behind this design (about loading C
libraries into different namespaces), but we have only one ffi.cdef,
thus comes my original question that if we can have different cdef's
namespaces too. After your explanation, I am thinking then why not:
ffi.load(path_to_LibA); ffi.cdef[[ LibA_declarations... ]]
ffi.C.LibA_Init()
--or
local C = ffi.C
C.LibA_Init()
Please correct me if I am still wrong on the matter, thank you. :)
Best regards,
Johnson Lin