lua-users home
lua-l archive

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


David Jeske wrote:
 >> I have C_obj_goto, C_obj_viewfollow, C_obj_delete,

   I'd like to discuss naming conventions - if there are any "standards" or
"de facto" ways of keeping everything straight.  For example, you
apparently use a preface of "C_" for your library extensions.

   The situation I'm facing can be illustrated as follows, with a bit of
name mangling using '|' to separate the "owner" from the function:

   LIB|showjpeg    -- from the graphics library linked with host app
   HOST|showjpeg   -- wraps graphics library in host app
   LUAX|showjpeg   -- wraps HOST.showjpeg within host app with Lua calling
conventions
   LUA|showjpeg    -- name registered inside Lua for LUAX.showjpeg

   (The reason, currently, for separate HOST|showjpeg and LUAX|showjpeg is
that I may have need to call the routine directly from the host app and is
more convenient to call the HOST| version there.  If I eventually let Lua
take full control of the app's functionality, I'd then merge those two
functions into a single LUAX| version.)

   Now, I could make things very confusing and just pick random names for
all those related functions, but I'm thinking that's not a wise decision. 
;-)  So far, I've named all the host extensions functions "lx_*" (for "Lua
eXtension") and then registered the name without the decorated prefix,
like:  lua_register("showjpeg", lx_showjpeg).

   That's not bad, however even with only about a dozen functions
registered so far and a hundred lines of Lua code, it's already tricky to
see at a glance where host functions are being called.  I mean
showjpeg("whatever.jpg") just kind of hides out in there looking like it
might be a Lua-defined function, not a host extension.  Your big bold
capital "C_" method handles that problem.

   Any advice, suggestions, recommendations, common conventions?  Thanx.

   Cheers,

   Dave