From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/62124 Path: news.gmane.org!not-for-mail From: =?iso-8859-2?B?UHJvY2jhemthIEx1a+G5IEluZy4gLSBQb250ZXggcy4gci4gby4=?= Newsgroups: gmane.comp.tex.context Subject: Re: Lua programming conventions.. Date: Thu, 30 Sep 2010 11:35:24 +0200 Message-ID: References: <4CA385DE.5010802@gyza.cz> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed"; DelSp="yes" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1285839344 4028 80.91.229.12 (30 Sep 2010 09:35:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 30 Sep 2010 09:35:44 +0000 (UTC) To: "mailing list for ConTeXt users" Original-X-From: ntg-context-bounces@ntg.nl Thu Sep 30 11:35:42 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 1P1FYB-000455-T5 for gctc-ntg-context-518@m.gmane.org; Thu, 30 Sep 2010 11:35:39 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 2CB35CA6CD; Thu, 30 Sep 2010 11:35:38 +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 51b0xAgTOcNs; Thu, 30 Sep 2010 11:35:35 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 529E2CA6F9; Thu, 30 Sep 2010 11:35:35 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 18333CA6F9 for ; Thu, 30 Sep 2010 11:35:34 +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 fIhk3QUqaibq for ; Thu, 30 Sep 2010 11:35:30 +0200 (CEST) Original-Received: from filter3-nij.mf.surf.net (filter3-nij.mf.surf.net [195.169.124.154]) by balder.ntg.nl (Postfix) with ESMTP id CF780CA6CD for ; Thu, 30 Sep 2010 11:35:30 +0200 (CEST) Original-Received: from mail.pontex.cz (mail.pontex.cz [89.233.168.98]) by filter3-nij.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o8U9ZTDF023760 for ; Thu, 30 Sep 2010 11:35:30 +0200 Original-Received: from localhost ([127.0.0.1]) by mail.pontex.cz (Kerio MailServer 6.6.2) for ntg-context@ntg.nl; Thu, 30 Sep 2010 11:35:27 +0200 In-Reply-To: User-Agent: Opera Mail/10.10 (Win32) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=89.233.168.98; country=CZ; region=52; city=Prague; latitude=50.0833; longitude=14.4667; http://maps.google.com/maps?q=50.0833,14.4667&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0dDcVztxF - dcd35b96e533 - 20100930 X-Scanned-By: CanIt (www . roaringpenguin . com) on 195.169.124.154 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:62124 Archived-At: 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 = 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 ___________________________________________________________________________________