lua-users home
lua-l archive

Ability to change C module by mere file renaming (Lua 5.1)

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


While it is possible for Lua modules (5.1) to be renamed simply by renaming their carriage file, this is not directly so for C modules. However, there is a mechanism described for being able to use two versions of a same package at once ("require 'v1-mod'" loads "v1" file but calls "luaopen_mod()"). Now, why make it so complicated? Why not just say, that in the absence of "luaopen_myfilename()" function, a "luaopen_init()" (or similar) will be called. What was the reason behind making module initialization functions carry the module name(space) anyhow? I think there is/was some, was it the static building situation (linking a module statically with the main Lua executable)? Is there any other reason for that behaviour? With the "defaults to luaopen_init" I think the whole "-" notation could be removed. It sounds potentially hazardous, I won't be able to make a "sdl-mixer" submodule, would I?
-ak
(hoping the signal/noise is right on this one...:)

AltStyle によって変換されたページ (->オリジナル) /