lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Tue, Jun 6, 2017 at 10:03 AM, Sean Conner <> 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 [1] 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)
> [1]     I was playing around with it about fifteen years ago and decided to
>         convert my site [2] to XML, and use XSLT to convert it to HTML (and
>         to generate all links between pages and sections)
> [2]

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).