[GRASS-dev] Tabs and spaces in C code
Paul Kelly
paul-grass at stjohnspoint.co.uk
Wed Aug 20 16:10:17 PDT 2014
Hello, I occasionally still glance at GRASS e-mails sometimes, and this
thread just caught my eye!
On 20/08/14 22:35, Vaclav Petras wrote:
> On Wed, Aug 20, 2014 at 5:14 PM, Markus Neteler <neteler at osgeo.org
> <mailto:neteler at osgeo.org>> wrote:
>
> The discussion was in 2008, for some pointers, see
>
> http://lists.osgeo.org/pipermail/grass-dev/2008-April/037622.html
> ...
>
> Thanks Markus for the links. In the emails I see a lot of discussion
> about tab being 8 spaces wide versus some other width. And I see that 8
> spaces for a tab is probably the ideal (at least it was).* However, I
> don't see the reasons for having first level of indent 4 spaces and
> second 1 tab.
I think there was no discussion of it at the time simply because no one
disagreed with Glynn's suggestion for 4-space indents! Certainly I have
always felt it is a nice length. Any shorter and it is hard to see the
indentation at a glance; any longer and long lines can start to
disappear off the right-hand edge of your screen, requiring horizontal
scrolling, which can quickly get very annoying.
Using a tab character instead of 8 spaces also saves 7 bytes from the
length of the file.
> This means that first level of indent is 1/2 of a tab? I
> don't think this is a good idea.
Well it is no problem if all developers always use 8-character tabs. I
agree it can seem a bit "ugly" though. If mixed tabs and spaces were to
be banned my preference would always be to replace tabs with 8 spaces
(although that would add 7 extra bytes per tab to the filesize!).
> * If you are using only tabs it really does not matter "how long" tab
> (in spaces) is because indentation levels are defined in number of tabs
> (not spaces) and the number is natural number (naturally).
Well it would mean all developers would need to set the tab spacing in
their editors to 4 spaces (in order for files to appear the same as
now). So it would mean requiring extra effort on the part of the
majority of people who use 8-character tabs, just to cater to the
minority who like to use tabs of a different length. I'm just playing
devil's adocate there of course, but if it had to be changed I
definitely think all spaces (a la FFmpeg) is a better option than all
tabs...
Perhaps a survey as to the tab settings used by all GRASS developers
would be a good idea?
Paul
More information about the grass-dev
mailing list