lua-users home
lua-l archive

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


It was thus said that the Great 书呆彭, Peng Yi once stated:
> 
> and for some projects, the namespace for functions, variables and constants 
> in the document
> 
> is inconsistent with (sometimes even wrong) the module name.
> 
> for example,
> 
>     IUPLua -> (no luarock) -> local iup = require 'iuplua'
>     wxLua -> (no luarock) -> local wx = require 'wx'
>     Lua-SDL2 -> luarocks install lua-sdl2 -> local SDL = require 'SDL'
>     LuaFileSystem -> luarocks install luafilesystem -> local lfs = require 
>     'lfs'
>     LuaGL -> luarocks install luagl -> local gl = require 'luagl'

  I don't necessarily see these as all being inconsistent.  The ones I don't
are LuaGL (the module name is just the lower case of the name), IUPLua
(same).  The SDL module is slightly inconsistent, but the project name has
Lua tacked on to probably distinguish itself from a Python binding or a Ruby
binding.  The wxLua and LuaFileSystem are the ones I would classify as
inconsistent.  The worse module I've come across in this regard is LuaXML.

	Project name:	LuaXML
	Luarocks:	luaxml
	require:	LuaXml
	module:		xml (for Lua 5.1)

  The fact that 

		require "LuaXml"

pollutes the global namespace (in Lua 5.1---we still use that at work) just
annoys me (for Lua greater than 5.1 this isn't an issue).

> I am NOT suggesting any naming schema or guidelines here. I have my
> personal taste too. I don't mean to start a debate, or even a war about
> this. I am just curious about what's other people's opinions on this
> topic. this helps me to choose names when I release my code to the public.

  I place mine under a namespace (based on a domain name I control), which
isn't a popular opinion around here ("Bad form!  Too much like Java!  And
what happens when you lose control of the domain?") but I do it to avoid
conflicting with an existing project (there are at least six different
syslog modules, a copule of signal modules, and a couple of socket modules).

  But, the project name (such as it is), the Luarocks name, the require
name and the module name (for Lua 5.1) all match, so it's easy to know what
to require.

  -spc