On Thu, 30 Sep 2010 10:47:42 +0200, Patrick Gundlach <patr...@gundla.ch> wrote:

Hi,

besides that what Luigi wrote, I'd recommend the Lua users wiki. Don't take everything there as 
"perfect" or "the official way", as it is just a users wiki, like our wiki.

http://lua-users.org/wiki/

Hello,

I'd say there is no universal naming convention.

For example I found local variables written with upper case 
(http://lua-users.org/wiki/AsciiMenu) ("local DASHES = string.rep('-', 80)") - 
it is not very common in programming to name local variables with upper case.

But in this case -
- it was probably to mark the variable as CONSTANT (as Lua doesn't have "const" 
keyword like C, where uppercase names are generally used for macros as constants or 
enums).

So:

- namespaces (modules) are generally named with lowercase names 
('mynamespace.') (like in C? 'std::', 'boost::'),

- variables are generally named with lowercase names ('_' may be used inside, 
so we get 'myvar' or 'my_var')

- - constants with uppercase? ("local PFX = '#'"?) May be.

- - global variables? One may prefer prefixing such variables somehow, so we get 
'_my_pfx' (or '_MyPfx' or '_myPfx')? (In C/Cpp, personally I use the 'g' prefix and camel 
notation, so I get 'gMyVar', opposite to all other vars with lowercase names like 
'my_inner_var'.) But if a variable is to be global, it's better to encapsulate it to a 
namespace; thus "mark of globality" in the name gets unnecessary as we access 
the variable like 'mynamespace.var' (it's obvious the variable is global for that 
namespace).

- functions? Naming like 'thisIsMyFunction()' (camel convention) is quite often, but one 
may prefer C-like naming ('this_is_my_function()' - so like internal variables?) or 
"TeX" convention ('thisismyfunction()') (natural to standard function, so we 
don't have 'string:g_sub()' or 'string:gSub()' but 'string:gsub()').

I'd say this to a wider discussion. You may get inspired from existing code as 
Patrick wrote, or e.g. to have a look into .lua scripts in ctx minimals.

Lukas

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to