lua-users home
lua-l archive

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


Johnson Lin wrote:
> I'd like to write
> 
> LibA.Init()
> LibB.Init()
> 
> but that's not going to happen for now, because you can have only one
> "Init".

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().

> or I'll have to use
> 
> LibA.Init() --renamed
> LibB.LibB_Init() -- can't rename to Init
> 
> although it's very unlikely to happen,

If it's that unlikely, then don't rename these few symbols.

> but even if we don't rename
> anything, won't there be a chance that we ffi.load() two libraries
> which already expose conflict names?

You can't sensibly use conflicting names in C, either. IMHO your
worry is a bit more on the hypothetical side.

--Mike