lua-users home
lua-l archive

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

> My question is though, why is the global not created?  Having it the way
> it is, it seems to me that you can never be sure that the global exists
> unless you explicitly create it, therefore making the creation in the
> first instance redundant.

To call luaL_register for the same library multiple times is not
a common scenario (among other things 'require' should avoid
that). However, what is somewhat more common is to call luaL_register to
add new stuff to an already created library.  If someone required module
'a', then erased global 'a', and then required module 'b' (which happens
to add new stuff into module 'a'), it seems reasonable not to re-create
the global. In this scenario, the global exists unless you explicitly
deleted it, and does not exist if you explicitly deleted it.

-- Roberto