lua-users home
lua-l archive

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


It was thus said that the Great Francisco Olarte once stated:
> On Tue, Oct 11, 2016 at 10:13 AM, Sean Conner <sean@conman.org> wrote:
> >   What?  You are still using a pysical VT-100 in this day and age?  Stuck
> > with 80x24 text window?
> 
> Even if you are not limited by the display ( and I've seen code which
> overflowed a 4k monitor for a not so long function ) too much vertical
> space can be an issue. 

  I was programming in assembly language long before I came to C.  Assembly
code is very vertical in nature and thus, I got used to it.  And when I came
to C, I carried over my predilection for vertical code.

  I never did like having the brace at the end of a line as I found it got
lost, and it made it difficult (to me) to visually match braces [1].  Over
about a year, I came to my current coding style (which hasn't changed all
that much [4][5]).  My style is as much practical as it is aesthetic (granted,
what *I* find practical and aesthetic, but I can provide *my* justifications
for why I do what I do).

> I normally prefer to split the code in chunks I
> can scan confortably ( and I cannot scan more than about .4/.5 m ) for
> easier comprehension. Sometimes braces in its own line make this hard,
> and I feel they do not add anything ( I use cuddled elses, last brace
> in its line, as for me the if opens a block, having a brace is a
> detail, and the else / else if separates blocks, braces are just a
> detail, and the last brace is the closer, being a brace or an end like
> in lua is just a detail).

  So you must love Pytho which did away with such cluttering detail.

  Also, a question, do you do:

	int main(int argc,char *argv[])
	{   /* <---- look!  an opening brace on its own line!

  or

	int main(int argc,char *argv[]) {

  or

	int
	main(int argc,char *argv[])
	{

  or

	int
	main(int argc,char *argv[]) {

  Just curious as to where you might break your own pattern 8-P

  (Another side question---do you do '*argv[]' or '**argv'?)

  -spc (I'm still in the process of refining my Lua coding style ... )

[1]	Yes, I know---most text editors can match the pairing characters.
	But at the time I was using an editor that lacked that feature (or I
	never found it).  It stuck.  Much like my preferring print() style
	debugging as a way to work around lack of good debuggers for the
	language du jour. [2][3]

[2]	I first worked with Java back in 1996, back when it was just fresh
	from Sun, no debuggers, and only one book available on it.  

[3]	I'm also a language maven:

	http://blog.osteele.com/posts/2004/11/ides/

	Tools tend to lag behind languages.

[4]	About the biggest change is that I no longer put parenthesis around
	values being returned.  I used to do:

		return (foo);

	Now I do:

		return foo;

[5]	A good example:

	https://github.com/spc476/mod_blog/blob/0b9522e3032e11059458dff954dc429a99d77eb5/src/wbtum.c#L152