OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 8:43 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 70 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject: Re: C coding style
PostPosted: Thu Jun 30, 2011 5:20 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

Solar wrote:
According to chapter 5.2.2 of the standard, the source character set includes "control characters representing horizontal tab, vertical tab, and form feed" (whatever good that would do).


I vote for "no vertical tabs allowed" in the style guide! ;)


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Thu Jun 30, 2011 6:34 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7612
Location: Germany
I wouldn't even know how to enter them... :lol:

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Thu Jun 30, 2011 6:57 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
But we definitely should require a form feed after each function. :D

_________________
Developer of tyndur - community OS of Lowlevel (German)


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Thu Jun 30, 2011 12:07 pm 
Offline
Member
Member

Joined: Sun Jan 16, 2011 6:58 pm
Posts: 43
Location: United States
I'm not happy.

Image


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Thu Jun 30, 2011 12:18 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Brynet-chan deserves a different title, really. I haven't seen him win any awards. 8)

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Thu Jun 30, 2011 12:44 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 9:29 pm
Posts: 2426
Location: Canada
Combuster wrote:
Brynet-chan deserves a different title, really. I haven't seen him win any awards. 8)

I've gained some notoriety with my ability to kiss @$$, you know what I mean.

_________________
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Thu Jun 30, 2011 4:24 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
Getting back to the guide:

  • Pointer declarations ( int * a ) vs. dereferencing "( *a ) is a bad idea. The declaration syntax mimics expressions on purpose, I thought we were running away from edge cases. Next thing you know, we're either going to have to do stuff like ! b or char a [MAX]; --- I say we revert this.
  • I can understand the concern regarding the lack of nested comments in C, but this is a wiki; the restriction is kind of silly since we're not going to temporarily turn code off on the wiki.

I'm still pretending that treating sizeof differently than other operators is not an edge case :) The equivalent for addition, according to the current guide should be ( a ) + ( b ).

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Thu Jun 30, 2011 6:07 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
The whole purpose of a standard is to be a substitute for common sense (usually, because there is no common sense) :roll:

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Thu Jun 30, 2011 11:39 pm 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7612
Location: Germany
Well said. 8)

Love4Boobies wrote:
Pointer declarations ( int * a ) vs. dereferencing "( *a ) is a bad idea. The declaration syntax mimics expressions on purpose, I thought we were running away from edge cases. Next thing you know, we're either going to have to do stuff like ! b or char a [MAX]; --- I say we revert this.


There is the age-long discussion on int* b (grouping the type, avoiding errors in multiple pointer declarations in a comma-separated declaration list) vs. int *b (declaraction mimics use). I always felt that int * b was deflating that particular argument nicely... are you sure about that revert? You'll get right back into the discussion with any int* b advocates around?!?

Quote:
I can understand the concern regarding the lack of nested comments in C, but this is a wiki; the restriction is kind of silly since we're not going to temporarily turn code off on the wiki.


I admit that's an artifact of my "general project style" leaking into the Wiki guide. I feel that /* */ is just asking for trouble, and should best be avoided altogether... I removed the two lines advocating // only, but left the example comments in that form - that's better?

Quote:
I'm still pretending that treating sizeof differently than other operators is not an edge case :) The equivalent for addition, according to the current guide should be ( a ) + ( b ).


Well... sizeof isn't exactly "just like the other operators" to begin with. Unless, of course, you're using and or or. ;-)

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Fri Jul 01, 2011 3:17 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Love4Boobies wrote:
I can understand the concern regarding the lack of nested comments in C, but this is a wiki; the restriction is kind of silly since we're not going to temporarily turn code off on the wiki.
But the person who copied from the wiki might.

The fact that it's posted on the wiki only implies stricter rules than normal coding standards: the code needs to work both as web-readable and as actually useful code. Your logic that the wiki doesn't compile code, so let's type "while" with an capital does not make sense.

Quote:
I admit that's an artifact of my "general project style" leaking into the Wiki guide.
You know, I mentioned that one first. :wink:


In other words, why are we discussing things that are fine as a standard, but troublesome from a religious standpoint?

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Fri Jul 01, 2011 3:32 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7612
Location: Germany
As if I'd be listening to you. :twisted: 8)

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Fri Jul 01, 2011 3:43 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Ok, I see. Any resemblance to real persons, living or dead, is purely coincidental. :twisted:

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Fri Jul 01, 2011 7:32 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 26, 2009 2:48 am
Posts: 792
Combuster wrote:
so let's type "while" with an capital
Have you ever read the source code of the VAL linker? It's a nice piece of software, but the code uses the preprocessor so intensively that it doesn't even look like C anymore:
Code:
#define If      if ((
#define Then    )) {
#define And     ) && (
#define Or      ) || (
#define Else    } else {
#define ElseIf  } else if ((
#define EndIf   }
Talking about coding styles...


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Fri Jul 01, 2011 8:00 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
Combuster wrote:
Love4Boobies wrote:
I can understand the concern regarding the lack of nested comments in C, but this is a wiki; the restriction is kind of silly since we're not going to temporarily turn code off on the wiki.
But the person who copied from the wiki might.
I don't know about you, but most of us here don't agree with copypasta.

Quote:
The fact that it's posted on the wiki only implies stricter rules than normal coding standards: the code needs to work both as web-readable and as actually useful code. Your logic that the wiki doesn't compile code, so let's type "while" with an capital does not make sense.
I'm not sure writing illegal code helps with readability... People do go to great lengths to make code more readable. There has even been research showing that monospaced fonts are worse for readability but better for actual coding, which is why most textbooks don't use monospaced fonts.

Quote:
In other words, why are we discussing things that are fine as a standard, but troublesome from a religious standpoint?
K&R was fine as a standard too, until you proposed changes that come from your own religion. :wink: Not that your coding style is bad, but you see my point...

Next, I propose that we use digraphs, trigraphs, and <iso646.h> as much as possible. :lol:

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: C coding style
PostPosted: Fri Jul 01, 2011 8:14 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7612
Location: Germany
/me knocking the table with the hammer.

"Quiet please! Calm in the Courtroom!"

/me waits for the hubbub to die down.

"Prosecution has read the indictment on the subject of the Wiki Coding Styleguide."

{Some applause from the ranks.}

"Attorneys of Defense have filed objection on the subject of TABs vs. Spaces, and have grumbled about various minor matters without actually voicing (much) protest."

{Some laughter, some grumbling.}

"The subject of tabs vs. spaces is voted for at another place. If there is anyone in attendance who objects to any significant points of the style guide other than the TABs vs. Spaces issue, he may raise his voice now or be quiet forever."

/me glaring at the audience, daring anyone to speak up.

8)

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 70 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group