From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/62127 Path: news.gmane.org!not-for-mail From: Jaroslav Hajtmar Newsgroups: gmane.comp.tex.context Subject: Re: Lua programming conventions.. Date: Thu, 30 Sep 2010 11:49:00 +0200 Message-ID: <4CA45D0C.50702@gyza.cz> References: <4CA385DE.5010802@gyza.cz> Reply-To: hajtmar@gyza.cz, mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252"; Format="flowed" Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1285840156 7537 80.91.229.12 (30 Sep 2010 09:49:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 30 Sep 2010 09:49:16 +0000 (UTC) To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Thu Sep 30 11:49:12 2010 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P1FlH-0008Km-Gt for gctc-ntg-context-518@m.gmane.org; Thu, 30 Sep 2010 11:49:11 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 0B154CA786; Thu, 30 Sep 2010 11:49:11 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id iIfZSzDEGhK8; Thu, 30 Sep 2010 11:49:08 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 25DE7CA778; Thu, 30 Sep 2010 11:49:08 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id CA7BCCA778 for ; Thu, 30 Sep 2010 11:49:06 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id kabfkMitC7Te for ; Thu, 30 Sep 2010 11:49:04 +0200 (CEST) Original-Received: from filter5-ams.mf.surf.net (filter5-ams.mf.surf.net [192.87.102.73]) by balder.ntg.nl (Postfix) with ESMTP id 162ABCA773 for ; Thu, 30 Sep 2010 11:49:04 +0200 (CEST) Original-Received: from psi3.forpsi.com (smtpa.forpsi.com [81.2.195.204]) by filter5-ams.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with SMTP id o8U9n2rY009113 for ; Thu, 30 Sep 2010 11:49:03 +0200 Original-Received: (qmail 23229 invoked by uid 89); 30 Sep 2010 09:49:01 -0000 Original-Received: from unknown (HELO ?192.168.1.60?) (hajtmar@gyza.cz@188.116.72.12) by psi03 with ESMTPA; 30 Sep 2010 09:49:01 -0000 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; cs; rv:1.9.1.8) Gecko/20100216 Thunderbird/3.0.2 In-Reply-To: X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=81.2.195.204; country=CZ; region=79; city=Ktis; latitude=48.9167; longitude=14.1333; http://maps.google.com/maps?q=48.9167,14.1333&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0BDcVN2jK - 5fb8406f3c36 - 20100930 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.73 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:62127 Archived-At: 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=E1zka Luk=E1=9A Ing. - Pontex s. r. o. napsal(a): > On Thu, 30 Sep 2010 10:47:42 +0200, Patrick Gundlach = > 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 =3D 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 =3D '#'"?) 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 t= he Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-cont= ext webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________= ________