I thought it might be fun to run a simple vote to discover the most
preferred spacing style for a simple if statement with a single, simple
boolean test. By my count, there are 32 possible variations for this
case. Here is a complete list.
AA: if ( a > b )
AB: if ( a > b)
AC: if ( a >b )
AD: if ( a >b)
AE: if ( a> b )
AF: if ( a> b)
AG: if ( a>b )
AH: if ( a>b)
AI: if (a > b )
AJ: if (a > b)
AK: if (a >b )
AL: if (a >b)
AM: if (a> b )
AN: if (a> b)
AO: if (a>b )
AP: if (a>b)
AQ: if( a > b )
AR: if( a > b)
AS: if( a >b )
AT: if( a >b)
AU: if( a> b )
AV: if( a> b)
AW: if( a>b )
AX: if( a>b)
AY: if(a > b )
AZ: if(a > b)
BA: if(a >b )
BB: if(a >b)
BC: if(a> b )
BD: if(a> b)
BE: if(a>b )
BF: if(a>b)
So, rank the available options from your most favorite to your least
favorite. It is not necessary fully rank all available options. Two or
more options can be ranked as being essentially equivalent. An example
ballot would look like:
AA > AJ > AG > AP > AQ = AW = AZ = BF
In this case, AA AJ AG AP AQ AQ AZ & BF, are all ranked above those
options which were left unranked. AQ AW AZ & BF are considered
essentially equivalent in terms of which would be preferred over the
other.
Feel free to e-mail your ballot to me to keep the group from filling up
with the votes. I'll announce the results (if there are any to announce)
when I stop receiving votes.
If you're interested in the method I will use to determine the result,
you are welcome to ask me via a private message.
If this receives a sufficient amount of interest, I'll do more just like
it out of some morbid curiosity concerning what is the most preferred
(within well known limitations) style around here. 60 3108
In <1g****************************@verizon.net> eg******@verizon.net (Eric) writes: I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test.
You're wasting your time. There is no fun in a religious war about the
usage of white space to improve the code readability.
AJ: if (a > b)
IMHO, this is the best, as it uses the minimum amount of white space
for a maximum of effect. if(a > b) comes close, but I prefer to omit
the space before the left parenthesis only for function calls.
Of course, other people have different preferences and there is nothing
fun or interesting in that.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
"Eric" <eg******@verizon.net> wrote in message
news:1gdo7jq.3gkwmyn064qoN%eg******@verizon.net... I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test. By my count, there are 32 possible variations for this case. Here is a complete list.
AA: if ( a > b ) AB: if ( a > b)
void f1(void)
{
}
void f2(void)
{
}
void f3(void)
{
void (*f[])(void) = {f1, f2};
f[a > b]();
}
-:)
-Mike
Mike Wahler wrote: ... void f1(void) { }
void f2(void) { }
void f3(void) { void (*f[])(void) = {f1, f2}; f[a > b](); }
-:) ...
(a > b && (f1(), 1)) || (f2(), 1)
is more elegant since it doesn't need the extra array :O)
--
Best regards,
Andrey Tarasevich
Dan Pop wrote: eg******@verizon.net (Eric) writes:
I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test.
You're wasting your time. There is no fun in a religious war about the usage of white space to improve the code readability.
AJ: if (a > b)
IMHO, this is the best, as it uses the minimum amount of white space for a maximum of effect. if(a > b) comes close, but I prefer to omit the space before the left parenthesis only for function calls.
Of course, other people have different preferences and there is nothing fun or interesting in that.
The millenium has arrived, 1229 days late. Dan and I are in
complete agreement.
--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
On Wed, 12 May 2004 18:53:33 GMT, CBFalconer <cb********@yahoo.com>
wrote: Dan Pop wrote: eg******@verizon.net (Eric) writes:
I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test.
You're wasting your time. There is no fun in a religious war about the usage of white space to improve the code readability.
AJ: if (a > b)
IMHO, this is the best, as it uses the minimum amount of white space for a maximum of effect. if(a > b) comes close, but I prefer to omit the space before the left parenthesis only for function calls.
Of course, other people have different preferences and there is nothing fun or interesting in that.
The millenium has arrived, 1229 days late. Dan and I are in complete agreement.
Another vote for AJ - that's how I've configured my editor to do it.
--
Al Balmer
Balmer Consulting re************************@att.net
Style is a very subjective and personal consideration.
C and C++ programmers develop or adopt a style
in order to make their code easier for themselves
and other programmers to read, understand and maintain.
If you are developing your own style, there are no rules
except that you should try to be consistent.
Otherwise, you should try to adopt a style
with which other C and C++ programmers are comfortable,
familiar or that they will at least recognize.
Personally, I try to use the same punctuation rules
that are used for ordinary (mathematical) typesetting.
Here are my recommendations:
Terminators always follow immediately after an expression
x@ for all @ in {?, :, ,, ;}
and are followed by at least one white space.
Write
x? y: z
instead of
x ? y : z
or
x?y:z
and write
void f(int, int, int); void g(double);
instead of
void f(int,int,int);void g(double);
for example.
There is no space
between some binary operators and their operands
x@y for all @ in {::, ., ->, .*, ->*, *, /, %, &, ^, |}
but there is always a space
between other binary operators and their operands
x @ y for all @ in {+, -, <<, >>;, <, <=, >, >=, ==, !=,
&&, ||, =, *=, /=, %=, +=, -=, <<=, >>=, &=, |=, ^=}
except when expressions appear as subscripts.
Write
x + y
instead of
x+y
and
x*y
instead of
x * y
for example.
But you may wish to write
A[i+1][j-1]
instead of
A[i + 1][j - 1]
for example to subscript array A.
Most unary prefix operators never have any whitespace
between themselves and their operands
@x for all @ in {::, ++, --, ~, !, -, +, &, *}
but others do
@ x for all @ in {sizeof, new, delete, delete [], throw}
No unary postfix operators
x@ for all @ in {[], (), ++, --}
ever have any whitespace between themselves and their operands.
Use the normal typesetting rules for parentheses (),
square brackets [], angle brackets <> and curly brackets {}.
No space after (, [, < or { and no space before ), ], > or }.
Write
(x)
instead of
( x )
or
(x )
or
( x)
and write
[x]
instead of
[ x ]
or
[x ]
or
[ x]
for example.
There are, of course, exceptions
where extra white space helps to make your code more readable:
double A[2][3] = {{ 1, -1, 0},
{-10, 11, -21}};
Don't give identifiers cryptic, mangled names.
Use ordinary, meaningful words, conventional symbols
or abbreviations with annotations.
Write
double distance, velocity, acceleration, mass, Force;
Force = mass*acceleration;
or
double x; // distance
double v; // velocity
double a; // acceleration
double m; // mass
double F; // force
F = m*a;
for example.
Don't rely on defaults. Make declarations explicit.
Write
int i = 1;
instead of
i = 1;
to declare and initialize integer i and write
class X {
private:
// Representation
int I;
public:
// Constructors
// ...
};
instead of
class X {
// Representation
int I;
public:
// Constructors
// ...
};
to define the private data members of class X for example.
Use indentation to emphasize scope.
Everybody is comfortable with standard indentation:
void f()
{
// indent
}
But I indent curly brackets to the scope of the function body:
void f()
{
// indent
}
And I include the open curly bracket with the function heading:
void f() {
// indent
}
to save a line of code.
I always indent just two spaces at a time and
I place just one statement on each line so that
there is usually room for a comment at the end of each line
beginning in column 33 or 41.
Write
if (condition) {
// statements
}
instead of
if(condition) {
// statements
}
and
while (condition) {
// statements
}
instead of
while(condition) {
// statements
}
to distinguish flow control structures from function calls.
I use
// comment
for comments in C++ and I reserve
/*
a = b;
// comment
b = c;
*/
to comment out code which may include comments.
If you find yourself in an environment
that requires you to conform to style rules with which you are not
comfortable,
consider investing a little time and effort in a program like astyle
Artistic Style http://astyle.sourceforge.net/
which changes the appearance of C or C++ programs
by inserting or deleting whitespace.
Write
constant == variable
instead of
variable == constant
when comparing a variable to a constant for equality
so that if you write
constant = variable
by mistake, the compiler will detect the error.
I always write
x < y
or
x <= y
instead of
y > x
or
y >= x
when comparing two values so that the expression is true
when the left hand side is to the left of the right hand side
on the real number line.
Dan Pop <Da*****@cern.ch> wrote: In <1g****************************@verizon.net> eg******@verizon.net (Eric) writes:
I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test.
You're wasting your time. There is no fun in a religious war about the usage of white space to improve the code readability.
Not interested in discussion about what is best style.
I am only interested in the most preferred style based upon the rankings
of readers of comp.lang.c. AJ: if (a > b)
IMHO, this is the best, as it uses the minimum amount of white space for a maximum of effect. if(a > b) comes close, but I prefer to omit the space before the left parenthesis only for function calls.
So, you would rank:
AJ > AZ
Do you see any other merit differences between the various options or
would this ballot be the one you would submit?
Mike Wahler <mk******@mkwahler.net> wrote: "Eric" <eg******@verizon.net> wrote in message news:1gdo7jq.3gkwmyn064qoN%eg******@verizon.net... I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test. By my count, there are 32 possible variations for this case. Here is a complete list.
AA: if ( a > b ) AB: if ( a > b)
void f1(void) { }
void f2(void) { }
void f3(void) { void (*f[])(void) = {f1, f2}; f[a > b](); }
-:)
:-P
Ok, fine....there are more variants, but let's just stick to the ones I
defined.
Eric wrote: I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test. By my count, there are 32 possible variations for this case. Here is a complete list.
I reject any style with different spacing after '(' and before ')' or
with different spacing before and after an operator. That means your
list is immediately collapsed to:
AA: if ( a > b )
AG: if ( a>b )
AJ: if (a > b)
AP: if (a>b)
AQ: if( a > b )
AW: if( a>b )
AZ: if(a > b)
BF: if(a>b) So, rank the available options from your most favorite to your least favorite.
Count the 24 omitted ones as tied for dead last.
Of the remaining ones, I dislike (with decreasing vehemence)
a) shoving the '(' up next to the 'if',
b) omitting spaces around the operator '>', and
c) spaces afet '(' and before ')'.
This leaves the order as roughly
AJ > AA > AP > AZ > AG > AQ > BF > AW > (All the rest)
I am not adamant about any of this except for finding the non-symmetric
spacing unacceptable. Any style which you find readable is OK for your
own use, obviously. And I would change mine to fit any required house
style.
Eric wrote: I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test. By my count, there are 32 possible variations for this case. Here is a complete list.
AA: if ( a > b )
<snip> AJ: if (a > b)
<snip>
AJ > AA
I'd never consider using any of the rest.
Ed.
On Wed, 12 May 2004 12:17:18 -0400, in comp.lang.c , eg******@verizon.net
(Eric) wrote: I thought it might be fun to run a simple vote to discover the most preferred spacing style
You have a curious idea of fun..... :-)
AJ: if (a > b) AP: if (a>b) AX: if( a>b) BF: if(a>b)
any of those 4, not fussy. The others, with odd spacing round things, look
silly.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Ed Morton <mo****@lsupcaemnt.com> wrote: Eric wrote:
I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test. By my count, there are 32 possible variations for this case. Here is a complete list.
AA: if ( a > b ) <snip> AJ: if (a > b) <snip>
AJ > AA
I'd never consider using any of the rest.
Whether you'd consider using them or not is irrelevent. The only thing
that matters is whether you see any merit differences between them.
For example, based on your two rankings, it would seem that you value a
space between the if statement and the left paren.
So, it might be that you would rank the remaining ones which match that
feature below AA, but above those that do not have that feature.
But, then, AJ > AA could easily be your complete ranking.
thank you.
--
== Eric Gorr ========= http://www.ericgorr.net ========= ICQ:9293199 ===
"Therefore the considerations of the intelligent always include both
benefit and harm." - Sun Tzu
== Insults, like violence, are the last refuge of the incompetent... ===
Eric wrote: Not interested in discussion about what is best style.
I am only interested in the most preferred style based upon the rankings of readers of comp.lang.c.
To what end? It's one of the more useless discussion around.
Brian Rodenborn
On Wed, 12 May 2004 21:47:49 GMT, in comp.lang.c , eg*************@verizon.net (Eric) wrote: Ed Morton <mo****@lsupcaemnt.com> wrote:
Eric wrote:
> I thought it might be fun to run a simple vote to discover the most > preferred spacing style for a simple if statement with a single, simple > boolean test. By my count, there are 32 possible variations for this > case. Here is a complete list.
(snip) > AJ > AA
I'd never consider using any of the rest.
Whether you'd consider using them or not is irrelevent. The only thing that matters is whether you see any merit differences between them.
Thats a bit rude. The question you asked was which we preferred. Ed
answered that - AJ or AA.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Mark McIntyre <ma**********@spamcop.net> writes: On Wed, 12 May 2004 12:17:18 -0400, in comp.lang.c , eg******@verizon.net (Eric) wrote:
AJ: if (a > b) AP: if (a>b) AX: if( a>b) BF: if(a>b)
any of those 4, not fussy. The others, with odd spacing round things, look silly.
You don't think AX looks silly with its asymmetric spacing?
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
"Eric" <eg******@verizon.net> wrote in message
AQ > AZ > AA > AJ
all the rest are either too compact or show very odd use of whitespace.
Mark McIntyre <ma**********@spamcop.net> wrote: On Wed, 12 May 2004 21:47:49 GMT, in comp.lang.c , eg*************@verizon.net (Eric) wrote:
Ed Morton <mo****@lsupcaemnt.com> wrote:
Eric wrote:
> I thought it might be fun to run a simple vote to discover the most > preferred spacing style for a simple if statement with a single, > simple boolean test. By my count, there are 32 possible variations > for this case. Here is a complete list. (snip) > AJ > AA
I'd never consider using any of the rest. Whether you'd consider using them or not is irrelevent. The only thing that matters is whether you see any merit differences between them.
Thats a bit rude.
I'm sorry you feel that way.
The question you asked was which we preferred. Ed answered that - AJ or AA.
I asked people to rank the available options from most to least
preferred, not to rank only the options they would actually consider
using.
It is not necessary to rank all of the available options and two or more
options can be ranked differently.
However, if one see a merit difference between two or more of the
available options, they should be ranked. Only by doing this or assuming
this has been done can the most preferred option be found.
Is this clear now?
--
== Eric Gorr ========= http://www.ericgorr.net ========= ICQ:9293199 ===
"Therefore the considerations of the intelligent always include both
benefit and harm." - Sun Tzu
== Insults, like violence, are the last refuge of the incompetent... ===
Eric <eg*************@verizon.net> wrote: Ed Morton <mo****@lsupcaemnt.com> wrote:
Eric wrote:
I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test. By my count, there are 32 possible variations for this case. Here is a complete list.
AA: if ( a > b ) <snip> AJ: if (a > b) <snip>
AJ > AA
I'd never consider using any of the rest.
Whether you'd consider using them or not is irrelevent. The only thing that matters is whether you see any merit differences between them.
I am sorry if my bluntness caused offense.
I am sincerely interested in whether you see any further merit
differences among the remaining options.
--
== Eric Gorr ========= http://www.ericgorr.net ========= ICQ:9293199 ===
"Therefore the considerations of the intelligent always include both
benefit and harm." - Sun Tzu
== Insults, like violence, are the last refuge of the incompetent... ===
Eric wrote: I am sorry if my bluntness caused offense.
I see that you've already met some of our indigenous trolls.
If you decide to continue your subscription to the comp.lang.c newsgroup,
you will learn to recognize and ignore them.
E. Robert Tisdale wrote: Eric wrote:
I am sorry if my bluntness caused offense.
I see that you've already met some of our indigenous trolls. If you decide to continue your subscription to the comp.lang.c newsgroup, you will learn to recognize and ignore them.
A brilliantly insightful contribution. Perhaps we should add "savant" to
your title....
Eric wrote: Ed Morton <mo****@lsupcaemnt.com> wrote:
Eric wrote:
I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test. By my count, there are 32 possible variations for this case. Here is a complete list.
AA: if ( a > b ) <snip>
AJ: if (a > b)
<snip>
AJ > AA
I'd never consider using any of the rest.
Whether you'd consider using them or not is irrelevent. The only thing that matters is whether you see any merit differences between them.
I'm not sure where the confusion arose, but I appologise for not being
clearer. By saying "I'd never consider..." I meant that as in your
original example:
AA > AJ > AG > AP > AQ = AW = AZ = BF
In this case, AA AJ AG AP AQ AQ AZ & BF, are all ranked above those options which were left unranked.
AJ and AA are ranked above all those options that I left unranked.
Regards,
Ed.
Default User <fi********@boeing.com.invalid> wrote: Eric wrote:
Not interested in discussion about what is best style.
I am only interested in the most preferred style based upon the rankings of readers of comp.lang.c.
To what end? It's one of the more useless discussion around.
Why must fun have a purpose?
However, it does fit with another hobby of mine (which I also view as
fun) within which it would be quite useful.
On Wed, 12 May 2004 12:17:18 -0400, eg******@verizon.net (Eric) wrote: I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test. By my count, there are 32 possible variations for this case.
[snip]So, rank the available options from your most favorite to your least favorite.
[snip]
AJ > AZ > AP > BF > AA = AQ > AG = AW > AL = AN = BB = BD
--
aib
ISP e-mail accounts are good for receiving spam.
"CBFalconer" <cb********@yahoo.com> wrote in message
news:40***************@yahoo.com... Dan Pop wrote: eg******@verizon.net (Eric) writes:
I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test.
You're wasting your time. There is no fun in a religious war about the usage of white space to improve the code readability.
AJ: if (a > b)
IMHO, this is the best, as it uses the minimum amount of white space for a maximum of effect. if(a > b) comes close, but I prefer to omit the space before the left parenthesis only for function calls.
Of course, other people have different preferences and there is nothing fun or interesting in that.
The millenium has arrived, 1229 days late. Dan and I are in complete agreement.
This is my preferred style too.
How about people style for the following?
x = (a==3 ? 5 : 60);
Allan
Eric wrote: I thought it might be fun to run a simple vote to discover the most preferred spacing style for a simple if statement with a single, simple boolean test. By my count, there are 32 possible variations for this case. Here is a complete list.
AJ: if (a > b)
This is K&R style and the most common I've seen over the years.
It's my style as well. I wonder what the C standard has to say
about this; I mean implicitly of course.
Kees
Eric wrote: Default User <fi********@boeing.com.invalid> wrote:
To what end? It's one of the more useless discussion around.
Why must fun have a purpose?
For certain very dull definitions of "fun", I suppose.
However, it does fit with another hobby of mine (which I also view as fun) within which it would be quite useful.
If it's as "fun" as the first item, please don't hesitate to keep me in
the dark.
Brian Rodenborn
In <40*********************@news.xs4all.nl> Case <no@no.no> writes: Eric wrote:
AJ: if (a > b)
This is K&R style and the most common I've seen over the years. It's my style as well. I wonder what the C standard has to say about this; I mean implicitly of course.
The C standard uses the K&R style in its examples:
if (u.n.alltypes == 1)
if (sin(u.nf.doublenode) == 0.0)
/* ... */
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
In <c8**********@news.freedom2surf.net> "Allan Bruce" <al*****@TAKEAWAYf2s.com> writes: How about people style for the following?
x = (a==3 ? 5 : 60);
Why handle == differently than the other operators?
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
"Dan Pop" <Da*****@cern.ch> wrote in message
news:c8**********@sunnews.cern.ch... In <c8**********@news.freedom2surf.net> "Allan Bruce"
<al*****@TAKEAWAYf2s.com> writes:
How about people style for the following?
x = (a==3 ? 5 : 60);
Why handle == differently than the other operators?
Dan
I like to keep the comparison as a single statement and then separate the
true and false conditions. I think the lack of whitespace at the start
clarifies what is being done. I think
x = (a == 3 ? 5 : 60) ;
is a bit messier. another example might be:
x = (someFunction(a) ? Value1 : Value2);
Allan
Default User <fi********@boeing.com.invalid> wrote: However, it does fit with another hobby of mine (which I also view as fun) within which it would be quite useful.
If it's as "fun" as the first item
Actually, it's far better.
I find the topic of single winner election methods to be fascinating.
Unfortunately, it isn't that easy to obtain genuine ranked ballots
because where a ranked ballot method is used in real life the actual
ballots are not generally made available because of privacy concern.
It is extremely useful to be able to collect real ballots so that
various resolution methods can be compared.
I personally do not believe it would be overstating the situation to
claim that using a good single winner election method, when three or
more candidates are available, would offer benefits to the whole of
society and I find working towards the betterment of society to be fun.
For more information: http://en.wikipedia.org/wiki/Voting_system http://electionmethods.org/ http://bcn.boulder.co.us/government/approvalvote/ http://en.wikipedia.org/wiki/Condorcet_method http://en.wikipedia.org/wiki/Approval_voting
As a side note, the Debian Project
( http://en.wikipedia.org/wiki/Debian), which some of you may be familiar
with, uses a Condorcet Method to make certain decisions. Ever wondered
why?
Dan Pop wrote: In <40*********************@news.xs4all.nl> Case <no@no.no> writes:
Eric wrote:
AJ: if (a > b)
This is K&R style and the most common I've seen over the years. It's my style as well. I wonder what the C standard has to say about this; I mean implicitly of course.
The C standard uses the K&R style in its examples:
if (u.n.alltypes == 1) if (sin(u.nf.doublenode) == 0.0) /* ... */
Thanks again Dan for your standard insight in this very important
matter! ;-)
This closes the discussion; we must all obey the C standard. The
styles other than AJ are blatantly off-topic.
Kees
In <c8**********@news.freedom2surf.net> "Allan Bruce" <al*****@TAKEAWAYf2s.com> writes: "Dan Pop" <Da*****@cern.ch> wrote in message news:c8**********@sunnews.cern.ch... In <c8**********@news.freedom2surf.net> "Allan Bruce"<al*****@TAKEAWAYf2s.com> writes:
>How about people style for the following? > >x = (a==3 ? 5 : 60);
Why handle == differently than the other operators?
Dan
I like to keep the comparison as a single statement and then separate the true and false conditions. I think the lack of whitespace at the start clarifies what is being done. I think x = (a == 3 ? 5 : 60) ; is a bit messier.
The *right* way of dealing with "messiness" is by adding parentheses, not
by removing white space. So, if you feel uncomfortable with
x = (a == 3 ? 5 : 60);
replace it by:
x = ((a == 3) ? 5 : 60);
another example might be: x = (someFunction(a) ? Value1 : Value2);
Unless someFunction(a) returns a conceptually boolean value (like the
isxxx() functions from <ctype.h>), omitting the explicit text is not a
good idea.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
On Thu, 13 May 2004, Allan Bruce wrote: How about people['s] style for the following?
x = (a==3 ? 5 : 60);
I used to write
x = (a == 3) ? 5 : 60;
but these days I have taken to the style which I see is also
advocated by ERT:
x = (a == 3)? 5: 60;
It's shorter, and better parallels English typographical rules.
Note that I've dropped the parentheses around the whole ?:
expression, since I don't think they add to readability. They
certainly add to "non-ambiguity," but I would trust the reader
to figure out that reading the statement as
(x = (a==3))? 5: 60;
would be nonsensical. :)
-Arthur eg******@verizon.net (Eric) writes: It is extremely useful to be able to collect real ballots so that various resolution methods can be compared.
I personally do not believe it would be overstating the situation to claim that using a good single winner election method, when three or more candidates are available, would offer benefits to the whole of society and I find working towards the betterment of society to be fun.
But your poll is not very likely to produce different results with
different methods. To achieve that, you would have to pick an example
where people tend to vote "tactically" in a single vote system (like
"I want candidate `N' to become president, but he doesn't stand a chance
of winning anyway, so I'll vote for my second choice, candidate `K',
whom I still prefer over candidate `B'").
As a side note, the Debian Project (http://en.wikipedia.org/wiki/Debian), which some of you may be familiar with, uses a Condorcet Method to make certain decisions. Ever wondered why?
No, never wondered why. The mathematical properties which make
Condorcet best-suited in this case are well-known, after all.
Martin
--
,--. Martin Dickopp, Dresden, Germany ,= ,-_-. =.
/ ,- ) http://www.zero-based.org/ ((_/)o o(\_))
\ `-' `-'(. .)`-'
`-. Debian, a variant of the GNU operating system. \_/
"Allan Bruce" <al*****@TAKEAWAYf2s.com> writes: How about people style for the following?
x = (a==3 ? 5 : 60);
I prefer
x = (a == 3 ? 5 : 60);
As soon as one of operands of the conditional operator gets slightly
more complex, I prefer
x = (a == 3
? 5
: 60);
Martin
--
,--. Martin Dickopp, Dresden, Germany ,= ,-_-. =.
/ ,- ) http://www.zero-based.org/ ((_/)o o(\_))
\ `-' `-'(. .)`-'
`-. Debian, a variant of the GNU operating system. \_/
Eric wrote: Actually, it's far better.
Turned out to be far worse. At least the original question was
marginally on-topic.
You had no real interest in the subject, but instead wanted to waste the
of those on the newsgroup. Capital.
Oh, and:
*plonk*
Brian Rodenborn
"Dan Pop" <Da*****@cern.ch> wrote in message
news:c8**********@sunnews.cern.ch... In <c8**********@news.freedom2surf.net> "Allan Bruce"
<al*****@TAKEAWAYf2s.com> writes:
"Dan Pop" <Da*****@cern.ch> wrote in message news:c8**********@sunnews.cern.ch... In <c8**********@news.freedom2surf.net> "Allan Bruce" <al*****@TAKEAWAYf2s.com> writes:
>How about people style for the following? > >x = (a==3 ? 5 : 60);
Why handle == differently than the other operators?
Dan
I like to keep the comparison as a single statement and then separate the true and false conditions. I think the lack of whitespace at the start clarifies what is being done. I think x = (a == 3 ? 5 : 60) ; is a bit messier.
The *right* way of dealing with "messiness" is by adding parentheses, not by removing white space. So, if you feel uncomfortable with
x = (a == 3 ? 5 : 60);
replace it by:
x = ((a == 3) ? 5 : 60);
another example might be: x = (someFunction(a) ? Value1 : Value2);
Unless someFunction(a) returns a conceptually boolean value (like the isxxx() functions from <ctype.h>), omitting the explicit text is not a good idea.
I'm nervous about disagreeing with Dan Pop, but I also like: >x = (a==3 ? 5 : 60);
for simple expressions. Also, I don't prefer parens when not needed, it
makes one have to go through a lot of paren counting if there is a bug.
--
Mabden
Something that calls itself Default User wrote: *plonk*
Please plonk me while you're at it.
"Mabden" <ma****@sbcglobal.net> wrote in
news:to****************@newssvr27.news.prodigy.com : Unless someFunction(a) returns a conceptually boolean value (like the isxxx() functions from <ctype.h>), omitting the explicit text is not a good idea.
I'm nervous about disagreeing with Dan Pop, but I also like:
>> >x = (a==3 ? 5 : 60);
for simple expressions. Also, I don't prefer parens when not needed, it makes one have to go through a lot of paren counting if there is a bug.
Then drop the unecessary ones you have included. ?: is higher in
precedence than = so you can just write:
x = 3 == a ? 5 : 60;
Not to rekindle this argument :-)
--
- Mark ->
--
Allan Bruce wrote: How about people style for the following?
x = (a==3 ? 5 : 60);
No!
int x = (3 == a)? 5: 60;
"E. Robert Tisdale" wrote: Something that calls itself Default User wrote:
*plonk*
Please plonk me while you're at it.
Not on your life Trollsdale. You are far too dangerous.
Brian Rodenborn
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:40**************@jpl.nasa.gov... Allan Bruce wrote:
How about people style for the following?
x = (a==3 ? 5 : 60);
No!
int x = (3 == a)? 5: 60;
Not bad, but I prefer to have parens around the whole, and to keep the ? and
: separate since there are three distinct parts to the expression.
int x = (3==a ? 5 : 60);
--
Mabden
Martin Dickopp <ex****************@zero-based.org> wrote: eg******@verizon.net (Eric) writes:
It is extremely useful to be able to collect real ballots so that various resolution methods can be compared.
I personally do not believe it would be overstating the situation to claim that using a good single winner election method, when three or more candidates are available, would offer benefits to the whole of society and I find working towards the betterment of society to be fun. But your poll is not very likely to produce different results with different methods.
Regardless of whether it actually does or not, I am interested in the
result.
To achieve that, you would have to pick an example where people tend to vote "tactically" in a single vote system
Not true.
It is entirely possible for different results to occur where people have
only cast (or we can at least assume this) sincere votes. You are
welcome to check out my ballot archives at: http://www.ericgorr.net/library/tiki...BallotArchives
or, if you like, it isn't difficult to produce theoretical examples
where I would simple declare people have voted sincerely and yet can
produce a different winner even among the Condorcet variants.
By 'sincere vote' I mean that regardless of how other voters may or may
not vote, voter A will always have Candidate X ranked above Candidate Y.
--
== Eric Gorr ========= http://www.ericgorr.net ========= ICQ:9293199 ===
"Therefore the considerations of the intelligent always include both
benefit and harm." - Sun Tzu
== Insults, like violence, are the last refuge of the incompetent... ===
"Default User" <fi********@boeing.com.invalid> wrote in message
news:40***************@boeing.com.invalid... "E. Robert Tisdale" wrote: Something that calls itself Default User wrote:
*plonk*
Please plonk me while you're at it.
Not on your life Trollsdale. You are far too dangerous.
here here
On Thu, 13 May 2004 00:25:57 GMT, in comp.lang.c , eg*************@verizon.net (Eric) wrote: Mark McIntyre <ma**********@spamcop.net> wrote:
On Wed, 12 May 2004 21:47:49 GMT, in comp.lang.c , eg*************@verizon.net (Eric) wrote:
>Whether you'd consider using them or not is irrelevent. Thats a bit rude.
I'm sorry you feel that way.
The question you asked was which we preferred. Ed answered that - AJ or AA.
I asked people to rank the available options from most to least preferred,
He did, AJ or AA, equally ranked, the rest ranked in last place. By
defiunition surely, anything he'd not use is ranked last.
Is this clear now?
Its clear that you're imposing conditions akin to those psychometric tests
which require you to rank "potato" "elephant" "psoriasis" and "mars" in the
order which most reminds you of Jello, and from that reveals that you're a
mad axe murderer*
By the way I've just realised you're Eric Gorr the Troll from 2003. I
propose to therefore respond no further in this thread, and see how it
develops. If your posts return to last year's trollishness....
*I've always wondered about that. Where /do/ mad axes come from? And why
would anyone murder them?
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
On Thu, 13 May 2004 11:32:44 -0400, in comp.lang.c , eg******@verizon.net
(Eric) wrote: Default User <fi********@boeing.com.invalid> wrote:
> However, it does fit with another hobby of mine (which I also view as > fun) within which it would be quite useful.
If it's as "fun" as the first item
Actually, it's far better.
I find the topic of single winner election methods to be fascinating.
You need to get out more. And possibly see a specialist.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
On Thu, 13 May 2004 23:21:05 +0100, "Allan Bruce"
<al*****@TAKEAWAYf2s.com> wrote: "Default User" <fi********@boeing.com.invalid> wrote in message news:40***************@boeing.com.invalid... "E. Robert Tisdale" wrote: > > Something that calls itself Default User wrote: > > > *plonk* > > Please plonk me while you're at it.
Not on your life Trollsdale. You are far too dangerous.
here here
And probably other places as well ;-)
--
Al Balmer
Balmer Consulting re************************@att.net
Mark McIntyre <ma**********@spamcop.net> wrote: By the way I've just realised you're Eric Gorr the Troll from 2003. I propose to therefore respond no further in this thread, and see how it develops. If your posts return to last year's trollishness....
Not a time period I am particularly proud of.
I apologize for all wrongs or offenses.
--
== Eric Gorr ========= http://www.ericgorr.net ========= ICQ:9293199 ===
"Therefore the considerations of the intelligent always include both
benefit and harm." - Sun Tzu
== Insults, like violence, are the last refuge of the incompetent... ===
On Thu, 13 May 2004 17:41:10 +0200, Case wrote: Dan Pop wrote: In <40*********************@news.xs4all.nl> Case <no@no.no> writes:
Eric wrote:
AJ: if (a > b)
This is K&R style and the most common I've seen over the years. It's my style as well. I wonder what the C standard has to say about this; I mean implicitly of course.
The C standard uses the K&R style in its examples:
if (u.n.alltypes == 1) if (sin(u.nf.doublenode) == 0.0) /* ... */
Thanks again Dan for your standard insight in this very important matter! ;-)
Genius comes standard, I guess. ;)
(Ok, enough bad puns.) This closes the discussion; we must all obey the C standard. The styles other than AJ are blatantly off-topic.
Kees
Heck, that wouldn't be a bad idea in general: I don't think anything would
be lost if the C programming community as a whole chose /a/ standard
formatting style, and K&R seems as good a pick as any. The GNU indent
program can work wonders with code that looks like it was passed through a
meat grinder, so most human-produced code from the last 15 years should be
fine for mechanical reformatting (it might have a problem with the
'a*=b'/'a=*b' ambiguity of proto-C compilers).
Of course, that's never going to happen.
(Ironic that the GNU indent program should be so useful here, as the GNU
Project itself likes a much different style, which indent defaults to
unless you feed it the right command line option.)
--
yvoregnevna gjragl-guerr gjb-gubhfnaq guerr ng lnubb qbg pbz
To email me, rot13 and convert spelled-out numbers to numeric form.
"Makes hackers smile" makes hackers smile. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: craig |
last post by:
I am curious about how many of you prefer style 1 vs. style 2, and why. Are
there names for these style?
style 1:
method {
}
|
by: Natt Serrasalmus |
last post by:
After years of operating without any coding standards whatsoever, the
company that I recently started working for has decided that it might be a
good idea to have some. I'm involved in this...
|
by: Ron Burd |
last post by:
Hi,
As my company is moving into C# they are enforcing the use of styling
convention in the source code, such as methods naming conventions, newlines,
etc.
Does someone know of products that...
|
by: Dotnetjunky |
last post by:
Hi,
So far, I've found tons of documents describing
recommended coding standards for C#, but not a single
piece on VB.NET yet.
Anybody here knows such a coding standards guideline on
VB.NET...
|
by: Mike Labosh |
last post by:
I realize that you people have not seen much of me other than some framework
responses I have posted.
I am primarily a VB guy (yes, you can laugh) But I have lurked here for
several years,...
|
by: benben |
last post by:
Is there an effort to unify the c++ coding standard? Especially
identifier naming.
Not a big issue but it would be annoying to have to incorporate
different coding styles simultaneously when...
|
by: ct-86 |
last post by:
http://www.cdbook.cn/book.asp?id=2393
Organizational and Policy Issues
1
0. Don't sweat the small stuff. (Or: Know what not to standardize.)
2
1. Compile cleanly at high warning levels.
4
2....
|
by: Robert Seacord |
last post by:
The CERT/CC has just deployed a new web site dedicated to developing
secure coding standards for the C programming language, C++, and
eventually other programming language.
We have already...
|
by: Jim Johnson |
last post by:
is this C style coding?
I don't seem to see much C++ code in this way.
is this a bad programming practice?
code seem ugly coding this way.
=================
|
by: MJ_India |
last post by:
Style 1:
struct my_struct
{
...
};
typedef my_struct my_struct_t;
Style 2:
typedef struct my_struct
{
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |