473,672 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detab/Entab( a little OT?)

mdh
K&R devote 4 exercises to Detab/Entab issues. An extremely cursory
search reveals entire religions following space vs tab
controversy.... so, I guess the exercises are not in a complete vacuum.
My question is how often C programmers have to deal with this issue in
real life and under which circumstances?

Apr 17 '07 #1
13 2823
mdh wrote:
K&R devote 4 exercises to Detab/Entab issues. An extremely cursory
search reveals entire religions following space vs tab
controversy.... so, I guess the exercises are not in a complete vacuum.
My question is how often C programmers have to deal with this issue in
real life and under which circumstances?
At my shop, it has happened enough that we have an official company-wide
whitespace rule (set down by an architect after *days* of holy wars), a
corresponding vimrc file for Vim users, and a policy where submitted
changes to version control will be rejected if the whitespace rules are
not honoured.
Apr 17 '07 #2
Clever Monkey said:
mdh wrote:
>K&R devote 4 exercises to Detab/Entab issues. An extremely cursory
search reveals entire religions following space vs tab
controversy... .so, I guess the exercises are not in a complete
vacuum. My question is how often C programmers have to deal with this
issue in real life and under which circumstances?
At my shop, it has happened enough that we have an official
company-wide whitespace rule (set down by an architect after *days* of
holy wars), a corresponding vimrc file for Vim users, and a policy
where submitted changes to version control will be rejected if the
whitespace rules are not honoured.
That's a bit silly, isn't it? Why not just mandate running it through
indent as part of the check-in process?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Apr 17 '07 #3
Richard Heathfield <rj*@see.sig.in validwrites:
Clever Monkey said:
[...]
>At my shop, it has happened enough that we have an official
company-wide whitespace rule (set down by an architect after *days* of
holy wars), a corresponding vimrc file for Vim users, and a policy
where submitted changes to version control will be rejected if the
whitespace rules are not honoured.

That's a bit silly, isn't it? Why not just mandate running it through
indent as part of the check-in process?
Or at least expand.

(For those not familiar with Unix tools, "indent" reformats C source
code, and "expand" expands tabs to spaces.)

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Apr 17 '07 #4
On 17 Apr, 20:22, Richard Heathfield <r...@see.sig.i nvalidwrote:
Clever Monkey said:
mdh wrote:
K&R devote 4 exercises to Detab/Entab issues. An extremely cursory
search reveals entire religions following space vs tab
controversy.... so, I guess the exercises are not in a complete
vacuum. My question is how often C programmers have to deal with this
issue in real life and under which circumstances?
At my shop, it has happened enough that we have an official
company-wide whitespace rule (set down by an architect after *days* of
holy wars), a corresponding vimrc file for Vim users, and a policy
where submitted changes to version control will be rejected if the
whitespace rules are not honoured.

That's a bit silly, isn't it? Why not just mandate running it through
indent as part of the check-in process?
On the off chance that the second question isn't facetious:
indent is often not sufficiently flexible and produces output
that is undesirable. IMO, it's best if a human makes the
final edits, but it's okay to have an automated script
reject or deny code. Within the last few months, I put a
hook script into my VCS that makes really basic whitespace
and column-width checks (eg the commit is rejected if I
have any trailing whitespace or any columns over 79
characters), and I was shocked at how much of my
code failed those simple checks. (Mostly trailing
whitespace errors.) I haven't yet attempted to mandate
compliance on anyone else, but I actually like having
the check in place. I haven't taken the leap yet and
put a hard limit on the number of lines in a function, though.

Apr 17 '07 #5
mdh
On Apr 17, 10:32 am, Clever Monkey <spamt...@cleve rmonkey.orgwrot e:
>
At my shop, it has happened enough that we have an official company-wide
whitespace rule (set down by an architect after *days* of holy wars), a
corresponding vimrc file for Vim users, and a policy where submitted
changes to version control will be rejected if the whitespace rules are
not honoured.
thanks
Apr 17 '07 #6
Keith Thompson wrote:
Richard Heathfield <rj*@see.sig.in validwrites:
>Clever Monkey said:
[...]
>>At my shop, it has happened enough that we have an official
company-wide whitespace rule (set down by an architect after *days* of
holy wars), a corresponding vimrc file for Vim users, and a policy
where submitted changes to version control will be rejected if the
whitespace rules are not honoured.
That's a bit silly, isn't it? Why not just mandate running it through
indent as part of the check-in process?

Or at least expand.
ITYM unexpand? ;-)

>
(For those not familiar with Unix tools, "indent" reformats C source
code, and "expand" expands tabs to spaces.)
Apr 17 '07 #7
Bjørn Augestad <bo*@metasystem s.nowrites:
Keith Thompson wrote:
>Richard Heathfield <rj*@see.sig.in validwrites:
>>Clever Monkey said:
[...]
>>>At my shop, it has happened enough that we have an official
company-wide whitespace rule (set down by an architect after *days* of
holy wars), a corresponding vimrc file for Vim users, and a policy
where submitted changes to version control will be rejected if the
whitespace rules are not honoured.
That's a bit silly, isn't it? Why not just mandate running it
through indent as part of the check-in process?
Or at least expand.

ITYM unexpand? ;-)
Certainly not.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Apr 17 '07 #8
Richard Heathfield wrote On 04/17/07 15:22,:
Clever Monkey said:

>>mdh wrote:
>>>K&R devote 4 exercises to Detab/Entab issues. An extremely cursory
search reveals entire religions following space vs tab
controversy. ...so, I guess the exercises are not in a complete
vacuum. My question is how often C programmers have to deal with this
issue in real life and under which circumstances?

At my shop, it has happened enough that we have an official
company-wide whitespace rule (set down by an architect after *days* of
holy wars), a corresponding vimrc file for Vim users, and a policy
where submitted changes to version control will be rejected if the
whitespace rules are not honoured.


That's a bit silly, isn't it? Why not just mandate running it through
indent as part of the check-in process?
On occasion a programmer can use unusual arrangements
of white space to draw attention to some aspect of the code
or to make some structure clearer than it might otherwise be.
Usually, this involves adjusting horizontal positions to
create vertical alignments, demonstrating a relationship.
Here's one (slightly trimmed) from one of my programs:

static const int columns[] = {
/* C1 C2 arg count watts */
-1, -1, -1, 1,

/* amps watt hours cost monthly kWh */
3, 1, 1, 1,

/* max watts max volts max amps min watts */
1, 1, 3, 1,

/* min amps power factor duty cycle power cycle */
3, 0, 0, 0,
};

It's a little table of numeric codes that control what the
program does with/to various fields in a line of input (I've
omitted the block comment that explains the encoding).

The excess horizontal space that aligns the code with
the field names is the sort of thing that often doesn't
survive automated format-standardizers. I submit that the
above would be significantly harder to read if it were
rearranged by a reformatter to produce:

static const int columns[] = {
/* C1 C2 arg count watts */
-1, -1, -1, 1,

/* amps watt hours cost monthly kWh */
3, 1, 1, 1,

/* max watts max volts max amps min watts */
1, 1, 3, 1,

/* min amps power factor duty cycle power cycle */
3, 0, 0, 0,
};

Yes, the table could be rearranged to keep the field
names close to the corresponding codes. For example:

static const int columns[] = {
-1, /* C1 */
-1, /* C2 */
...

.... but the chosen "tabular" layout is noticeably more
compact: a little over half as deep, even counting the
all-blank lines. (In the original, I get five fields to
the line and the savings is even greater still.) But
should I really be spending my time arranging my code in
reformatter-proof ways? These tools are supposed to be
my servants, not my masters!

Programmers should be free to use white space to make
their code easier to read, and some of those ways escape
the notice of most reformatters. That's why I think
reformatters should not be part of the "normal" flow of
source code creation and modification, even though they
are invaluable when you're trying to rescue a few reams
of crufty old code that's been patched into obscurity.

--
Er*********@sun .com
Apr 17 '07 #9
mdh wrote:
K&R devote 4 exercises to Detab/Entab issues. An extremely cursory
search reveals entire religions following space vs tab
controversy.... so, I guess the exercises are not in a complete vacuum.
My question is how often C programmers have to deal with this issue in
real life and under which circumstances?
Just make sure everyone in the team follows the same rules. Often
editors hide discrepancies and you only find them when you attempt to
difference versions of the same file to see what changed. This can be
very painful.

You should also agree and stick to a line ending convention (DOS or UNIX).

--
Ian Collins.
Apr 17 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3427
by: Ron Stephens | last post by:
I posted to my web site a fun little program called merlin.py today. Please keep in mind that I am a hobbyist and this is just a little hack, if you look at the code you will see that it is still possible to write spaghetti code, even with Python. I apologize, and I do intend to clean up the code, but it may take awhile. For now it works, with some bugs. It is a composite of a few scripts. The first, based on a script Max M uploaded to...
2
29008
by: hicham | last post by:
Hi, I am looking for help, i would like to know how can i use the endian.h and config.h to convert compiled files under solaris from BIG-ENDIAN to compiled files LITTLE-ENDIAN. I am working under linux debian 3.0 woody Thank you for your help.
18
3969
by: Philipp Lenssen | last post by:
I want to write a third installment of "Little Known HTML Facts"*. I would appreciate your input here. For one thing, I would like to remember what exactly those proprietary icons were you could use -- I believe something like "&happyface;" would display a happy face, and so on, for folders, disk drives, and other technical icons. I found something called "&folder;" and "&audio;" (straight from the horse's mouth, at the W3C) but can't...
8
27455
by: Perception | last post by:
Hello all, If I have a C-like data structure such that struct Data { int a; //16-bit value char; //3 ASCII characters int b; //32-bit value int c; //24-bit value }
2
6545
by: bhatia | last post by:
Hello all, If I have a C-like data structure such that struct Data { int a; //16-bit value char; //3 ASCII characters int b; //32-bit value int c; //24-bit value }
13
27273
by: junky_fellow | last post by:
Hi guys, I need to convert a big endian integer to little endian integer. (the integer is 4 bytes in size on my implementation). I came up with the following code. I need your comments on this. Please suggest any improvements that can be done. #include <stdio.h> int main(void) {
102
5074
by: BoogieWithStu22 | last post by:
I am running into a problem with a web page I have created when viewing it in IE6 on some machines. The page has a database lookup. The user enters an account name or number and clicks a lookup button. This hits an AS400 database looks for matches and returns a dataset that is used to populate a datagrid. The user then selects one of the entries from the list, this entry is used to populate a couple of textboxes on the page and a couple...
6
3175
by: Javier | last post by:
Hello people, I'm recoding a library that made a few months ago, and now that I'm reading what I wrote I have some questions. My program reads black and white images from a bitmap (BMP 24bpp without compression). It has it's words and dwords stored in little- endian, so I do a conversion to big-endian when reading full words or dwords. I have done this because my system is big-endian. But now... what if one compiles the library in a...
23
7036
by: Niranjan | last post by:
I have this program : void main() { int i=1; if((*(char*)&i)==1) printf("The machine is little endian."); else printf("The machine is big endian."); }
0
8508
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8854
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8704
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7484
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4253
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2849
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2104
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.