[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua Style Guide ?
- From: Russell Haley <russ.haley@...>
- Date: Tue, 6 Jun 2017 14:51:12 -0700
On Tue, Jun 6, 2017 at 10:03 AM, Sean Conner <email@example.com> wrote:
> It was thus said that the Great Russell Haley once stated:
>> Sorry for the top post.
>> Oh, and twenty indents? The version of Lua I use has a keyword called
>> 'function'. And adhering to 80 columns is just silly. It was silly 20
>> years ago when I started writing code.
> But where's the cutoff? I have some XSLT code  where some of the lines
> are long. Really long. Like 250 characters long:
> <xsl:param name="image"><xsl:value-of select="/site/section[@id='About']/subsection[position()=1]/page[position()=1]/@filename"/>.<xsl:value-of select="/site/section[@id='About']/subsection[position()=1]/page[position()=1]/img/@type"/></xsl:param>
> (note the two character indent)
> This is, in my opinion, a bit too long (but if broken up, would be a real
> mess and would probably mess up the output too much).
> I find 80 to be nice---I can fit several xterms side by side when
> programming (on my monitor at work---five side by side).
> -spc (It's not a hard rule wit me, but a guideline I try to follow)
>  I was playing around with it about fifteen years ago and decided to
> convert my site  to XML, and use XSLT to convert it to HTML (and
> to generate all links between pages and sections)
>  http://www.conman.org/
My preference is to maximize the amount of information on a single
screen. While 250 characters is very long, picking an arbitrary number
of characters applicable to computing in 1981 is suboptimal. Your
example of multiple xterms is one good reason to keep lines short, but
I can also easily put two windows at 150 characters side by side on a
reasonable modern monitor. After looking at some of my code, it seems
my lua lines are very short and my C# lines can get up to about 140
characters. Either way, I try to be descriptive rather than
restrictive in my code style. That means longer variable names and
sometimes putting everything on one line if it makes sense. One of my
current favorites in Lua is if/then/else on one line, which will
rarely fit in 80 characters:
if table.value == "another value" then number1 = number1 + 6 else
number1 = 0 end
(admittedly that looks much nicer in ZeroBrane with color coding).
- Lua Style Guide ?, J Doe
- Re: Lua Style Guide ?, Edu Araújo
- Re: Lua Style Guide ?, Pierre Chapuis
- Re: Lua Style Guide ?, steve donovan
- Re: Lua Style Guide ?, Soni L.
- Re: Lua Style Guide ?, Francisco Olarte
- Re: Lua Style Guide ?, Marc Balmer
- Re: Lua Style Guide ?, Dirk Laurie
- Re: Lua Style Guide ?, Russell Haley
- Re: Lua Style Guide ?, Sean Conner