From: Spam on
On Tue, 8 Jun 2010, rickman wrote:
>
> BTW, I don't live the the ever storage conscious Unix/Linux world.
> Real men use CR/LF pairs.
>
> Rick
>

If by "real men", you mean gen-X metrosexuals who require a mouse and gui
to run an operating system, then perhaps. In fact, when real men have a
question, the first thing they do is type "man" -- that ALWAYS helps 8-).

Rob.
From: Dombo on
rickman schreef:
> On Jun 7, 10:26 am, Spehro Pefhany <speffS...(a)interlogDOTyou.knowwhat>
> wrote:
>> On Mon, 7 Jun 2010 06:27:37 -0700 (PDT), rickman <gnu...(a)gmail.com>
>> wrote:
>>
>>
>>
>>> There is one other way to write this that I tend to use when coding.
>>> One of the "guides" to coding I read many years ago, perhaps in
>>> college said the smaller of the two choices in an if then else should
>>> be first. This makes it easier for the eye to scan the code and glean
>>> structure from the shape... a bit like the way I learned to read...
>>> look for the outline of the words rather than parsing every letter.
>>> Also,, it is not uncommon for the else and the if to be put on the
>>> same line to show that the "if" is the only statement within the
>>> else. The result is very clean, simple and uses much less space
>>> streamlining the code to the point that the structure is very clear to
>>> the eye. Oh, and you don't need all those parens for single
>>> statements.
>>> uint16_t Func1(uint16_t int1, uint16_t int2, uint16_t int3)
>>> {
>>> if (int1 != 32)
>>> return 3;
>>> else if (int2 != 16)
>>> return 2;
>>> else if (int3 != 8)
>>> return 1;
>>> else
>>> return 0;
>>> }
>>> Rick
>> Why waste all those linefeeds when you can simply write
>>
>> uint16_t func(uint16_t i1, uint16_t i2, uint16_t i3)
>> {return i1 != 32 ? 3: i2 != 16 ? 2: i3 !=8 ? 1 : 0;}
>>
>> ? ;-)
>
> I assume the winky means no response is needed?
>
> BTW, I don't live the the ever storage conscious Unix/Linux world.
> Real men use CR/LF pairs.

Real men don't need white space. If it was hard to write it should be
hard to read.
From: Mark Borgerson on
In article <4c0e3e50$0$14150$c3e8da3(a)news.astraweb.com>,
cfbsoftware(a)hotmail.com says...
> "David Brown" <david(a)westcontrol.removethisbit.com> wrote in message
> news:4c0dee1d$0$4111$8404b019(a)news.wineasy.se...
> >
> > As an example, consider the very common template:
> >
> > void foo(int *p) {
> > if (!p) return;
> > ... do something with *p
> > }
> >
> > That is clearer than:
> >
> > void foo(int *p) {
> > if (p) {
> > ... do something with *p
> > }
> > }
> >
> > The first version removes an extra layer of block indents, making the
> > function slightly flatter and slightly clearer.
> >
>
> I disagree. The fact that the second version is not flatter is a clear
> indication that the body is conditionally executed. If that were not true
> you could just make it flatter by removing all indentation!
>
>
>
If foo() is called in only a few places, might it not
be even more clear to have:

// in calling code

if(p)foo(p);


then you can get rid of all the conditionals in foo()
and move the readers awareness of the conditional test
a level up in the heirarchy.

That would work with the simple foo() shown here, but
wouldn't work if foo() did some action for all values
of p.


Mark Borgerson

From: D Yuniskis on
Hi Rick,

rickman wrote:
> BTW, the only rule I use is one that says the word "shall" shall not
> be used in coding guidelines.

+42
From: D Yuniskis on
Dombo wrote:
> Real men don't need white space. If it was hard to write it should be
> hard to read.

xctly!ndthydntndvwls!