Spacing issues

Vincent Lefevre vincent-opdarw at vinc17.org
Tue Feb 13 03:20:45 PST 2007


On 2007-02-12 23:21:45 -0600, Ryan Schmidt wrote:
> On Feb 10, 2007, at 20:58, Vincent Lefevre wrote:
> >A mix of tabs and spaces is bad since it won't look right in diffs,
> >for instance.
> 
> What do you mean, won't look right in diffs?

Bad indentation, making the diff less readable.

> What do you mean, mix of tabs and spaces?

Like what Emacs does *by default*, for instance:
  1st indentation: 2 spaces
  2nd indentation: 4 spaces
  3rd indentation: 6 spaces
  4th indentation: 1 tab
  5th indentation: 1 tab + 2 spaces
and so on.

But in a context diff, one gets 8 spaces (well, something equivalent)
for the 3rd indentation, and 1 tab for the 4th indentation, i.e. the
same indentation for both.

Note: of course, unified diffs are better, and the problem is less
visible with them. But one can also considered code that is commented
by mail, where the indent prefix is "> ".

> >Moreover, using tabs only is also a bad choice since
> >one can't align columns and a 8-column space is often too much for
> >a single indentation (even though some editors could be configured
> >to use fewer columns, this is not the case of terminals and web
> >browsers).
> 
> Right, tabs are bad for trying to indent additional columns since  
> different editors have different tab sizes.

Also, I forgot to say: having tabs in the sources is bad when patches
are put on the web, embedded in some other file (e.g. mail message on
mail archives), as tabs are converted into spaces, then the "patch"
command no longer works (unless the option to ignore spaces is used,
but it's better not to rely on it, in particular because it can break
indentation[*]). Ditto for trailing spaces.

[*] In Python, this may even break the code itself!

-- 
Vincent Lefèvre <vincent at vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)



More information about the macports-dev mailing list