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? 13 2805
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.
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.
Richard Heathfield <rj*@see.sig.invalidwrites:
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_Keith) 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"
On 17 Apr, 20:22, Richard Heathfield <r...@see.sig.invalidwrote:
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.
On Apr 17, 10:32 am, Clever Monkey <spamt...@clevermonkey.orgwrote:
>
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
Keith Thompson wrote:
Richard Heathfield <rj*@see.sig.invalidwrites:
>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.)
Bjørn Augestad <bo*@metasystems.nowrites:
Keith Thompson wrote:
>Richard Heathfield <rj*@see.sig.invalidwrites:
>>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_Keith) 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"
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
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.
Keith Thompson wrote:
Richard Heathfield <rj*@see.sig.invalidwrites:
>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?
[Richard's reply did not show up for me, so I'm replying here.]
No, because humans know what good code looks like, and not all the
existing code is formatted the same way -- this is life. We can correct
that as we go along, but it makes no sense to introduce multi-line
changes for no other reason than to satisfy a formatting tool.
Whereas a coder might break formatting by mistake once, which can easily
be corrected in their sandbox. So far (i.e., several years and several
times as many major releases later) this has not been found to be a
hardship.
What if we turn the question around? Why should we add the extra burden
of running a formatting tool by hand or as part of an automated (read:
"brittle") process when we can simply mandate guidelines easily
implemented and understood by coders?
I work at a multi-language, multi-platform shop. It is up to the human
working on the code to make the best decision, which works well. Legacy
code can just stay legacy for all we care, and the occasional format
disaster stays out of the archives and is easily fixed by using any text
editor in the known universe.
When I review changes, I don't /want/ to see any changes other than
those specific to the problem or feature it addresses. I don't care
that my diff tool can be set to ignore whitespace changes -- they are
still changes and change incurs risk no matter what sort of change it is.
For the record, only a small amount of the changes we make will be C.
The Holy War I mentioned was around Java, which was solved by having our
code formatted exactly like the code shipped from Sun. Our C code is
legacy, and there is no way anyone will accept running it through indent
-- it's formatted Good Enough for now. The only choice was tabs vs.
spaces, and I don't recall what the rule is. The architect arbitrarily
chose one and state This Is The Way It Is To Be. I set my editors
appropriately (most are smart enough to simply figure it out from
context) and have never had a problem.
Clever Monkey wrote:
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.
By whom? The tool or a warm body?
--
Ian Collins.
Ian Collins <ia******@hotmail.comwrote:
Clever Monkey wrote:
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.
By whom? The tool or a warm body?
Frequently the same thing, in this context.
Richard
Eric Sosman <Er*********@sun.comwrote:
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.
Most formatters (including indent) recognize special comments to
turn the automatic stuff off/on. Of course use of those are
subject to code review (another item which is off-topic here).
--
Thomas E. Dickey http://invisible-island.net ftp://invisible-island.net This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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
}
|
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
}
|
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...
|
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...
|
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...
|
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.");
}
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |