ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Lua programming conventions..
@ 2010-09-29 18:30 Jaroslav Hajtmar
  2010-09-29 19:05 ` luigi scarso
  2010-09-30  8:47 ` Patrick Gundlach
  0 siblings, 2 replies; 5+ messages in thread
From: Jaroslav Hajtmar @ 2010-09-29 18:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello, all..
Where can I read something about Lua programming conventions?

I mean programming conventions labeling local and global variables, 
table fields, Lua variables in modules, variables in namespaces etc. etc...
When names are written in capital letters, sign reserved for system 
variables, etc.?

Thanx Jarda
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Lua programming conventions..
  2010-09-29 18:30 Lua programming conventions Jaroslav Hajtmar
@ 2010-09-29 19:05 ` luigi scarso
  2010-09-30  8:47 ` Patrick Gundlach
  1 sibling, 0 replies; 5+ messages in thread
From: luigi scarso @ 2010-09-29 19:05 UTC (permalink / raw)
  To: hajtmar, mailing list for ConTeXt users

On Wed, Sep 29, 2010 at 8:30 PM, Jaroslav Hajtmar <hajtmar@gyza.cz> wrote:
> Hello, all..
> Where can I read something about Lua programming conventions?
>
> I mean programming conventions labeling local and global variables, table
> fields, Lua variables in modules, variables in namespaces etc. etc...
> When names are written in capital letters, sign reserved for system
> variables, etc.?
http://www.lua.org/pil/
and context *lua files

-- 
luigi
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Lua programming conventions..
  2010-09-29 18:30 Lua programming conventions Jaroslav Hajtmar
  2010-09-29 19:05 ` luigi scarso
@ 2010-09-30  8:47 ` Patrick Gundlach
  2010-09-30  9:35   ` Procházka Lukáš Ing. - Pontex s. r. o.
  1 sibling, 1 reply; 5+ messages in thread
From: Patrick Gundlach @ 2010-09-30  8:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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/

Patrick

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Lua programming conventions..
  2010-09-30  8:47 ` Patrick Gundlach
@ 2010-09-30  9:35   ` Procházka Lukáš Ing. - Pontex s. r. o.
  2010-09-30  9:49     ` Jaroslav Hajtmar
  0 siblings, 1 reply; 5+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2010-09-30  9:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Thu, 30 Sep 2010 10:47:42 +0200, Patrick Gundlach <patrick@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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Lua programming conventions..
  2010-09-30  9:35   ` Procházka Lukáš Ing. - Pontex s. r. o.
@ 2010-09-30  9:49     ` Jaroslav Hajtmar
  0 siblings, 0 replies; 5+ messages in thread
From: Jaroslav Hajtmar @ 2010-09-30  9:49 UTC (permalink / raw)
  To: ntg-context

Thanx Lukas
Thanks for the comprehensive answer - I needed to know.
Codes for own use probably does not make sense to solve, but I started 
to write a separate public ConTeXt module with many Lua code, so I want 
to meet Lua code conventions.
I also have my habits, but I want to code written as it should be.

Thanx Jarda


Dne 30.9.2010 11:35, Procházka Lukáš Ing. - Pontex s. r. o. napsal(a):
> On Thu, 30 Sep 2010 10:47:42 +0200, Patrick Gundlach 
> <patrick@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
> ___________________________________________________________________________________ 
>
>

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-09-30  9:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-29 18:30 Lua programming conventions Jaroslav Hajtmar
2010-09-29 19:05 ` luigi scarso
2010-09-30  8:47 ` Patrick Gundlach
2010-09-30  9:35   ` Procházka Lukáš Ing. - Pontex s. r. o.
2010-09-30  9:49     ` Jaroslav Hajtmar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).