[MPlayer-dev-eng] Indentation style (was: [PATCH] Fix useless dependencies in the stream lib)

Uoti Urpala uoti.urpala at pp1.inet.fi
Wed Apr 9 03:51:50 CEST 2008


On Wed, 2008-04-09 at 02:49 +0200, Alban Bedel wrote:
> On Wed, 09 Apr 2008 01:48:53 +0300
> Uoti Urpala <uoti.urpala at pp1.inet.fi> wrote:
> > I think there would be reason to expect a lot more disagreement over
> > tags than most code. The very existence of different tags assumes
> > there is no agreement over what is to be preferred. Tags affect the
> > whole file and so are a lot more likely to affect other people than
> > code changes. For code changes that involve some amount of effort a
> > reasonable default is that if there are no objective arguments for
> > preferring one way then the person making the changes gets to decide;
> > not so for tags.
> 
> At the start of this thread I mentioned "style" and that include tab
> vs. space as well. Indentation is not that bad to handle manually but
> having to switch between tab and space indentation within the same file
> is really, really annoying.

Do you really have to switch?

>  Now how you can, at the same time, argue for
> an overall common style and against common style within a file is
> beyond me. Sure it's not your holy grail, but it is still a step closer.

Trying to enforce a style within a file more strictly is still enforcing
a style. Enforcing different styles for different files is much worse
than enforcing a consistent style. Per-file styles is not really a step
toward overall consistency; it just sorts the different styles into
files, where overall consistency would require (mostly) removing some
styles.

> > I'm not talking only about files which already are mixed indentation.
> > My point was that if tags are needed to avoid a file _becoming_ mixed
> > indentation then it's questionable whether setting tags for any value
> > other than 4 space indentation is OK (I think that is clearly the most
> > "standard" one in MPlayer).
> 
> And while we all wait for the Great Reindentation, what is so bad in
> improving the work environment of most?

I don't think setting inconsistent per-file tags would be an
improvement.

> > If a file is edited enough by different people that tags are really
> > needed (assuming you consider mixed indentation a serious problem)
> > then it should probably use the most common indentation style.
> 
> My feeling is that most ppl introduce mixed styles just bcs they are
> too lazy to set their editor to a different style. Not bcs they think
> their pet style is so much better. And I strongly doubt that anybody
> would make an outcry to use their pet style when extending existing
> code.

Even if they don't make an outcry is there really that much reason to
even encourage using the existing nonstandard style (as long as there
isn't too much variation from one line to the next)? 

> > So you have no problem at all even with changing that file as a whole
> > to a common style and requiring all further changes to keep it?
> 
> Not really.
> 
> > Then exactly where do you draw the line where you DO have a problem?
> 
> I have problem with long debate leading nowhere, flamewars and waiting
> for something that might never happen.

So you think reindenting would be bad because you think it won't happen?
I don't see much logic in that.

> > Since you oppose a common indentation style overall I assume you must
> > oppose some such changes.
> 
> I don't like the idea much bcs I think it will waste a lot of time in
> pointless discussions and/or flamewars, while achieving very little
> practically.

I on the other hand do not see per-file styles achieving much.

> > > > functions in a different style is much less so IMO. So I think
> > > > that at least adding a new function in a common style should be
> > > > OK even if the rest of the file uses some weird style - adding
> > > > more code in a weird style even if the only person who likes that
> > > > style isn't currently working on the code is a problem too.
> > > 
> > > And who decide what "a weird style" is?
> > 
> > That does not need a definition based on the style itself here. Most
> > rare styles would be OK for examples.
> 
> And rare mean? That you don't use it?

A style used by few other people (doesn't correspond to any standard
switch of the indent program etc). If a person starting some part of the
program used some "private" style that shouldn't lead to such style
spreading if it's expanded by others.

> > >  What you seems to miss is that
> > > every file in the tree started with a consistent indentation.
> > 
> > You only focus on consistency, and only consistency within a file, as
> > the sole factor determining what is desirable. At least for myself a
> > file mixing a couple of most common styles plus a bit of some rare
> > style is more readable than a file written entirely in some
> > completely unique style.
> 
> This is about making writing easier, not reading.

You argue for making styles within files more consistent; if you only
concentrate on writing doesn't this only make it _harder_, not easier,
if you have to follow the existing style more closely and try to avoid
any "inconsistency"?

> > > Personally I don't give a damn about any pet indentation style, all
> > > I want is readable code and not having to mess with indentation and
> > > tab-expansion settings every time I open a file.
> > 
> > Then exactly why do you oppose a common style?
> 
> Because I find it pointless to impose the pet style of someone on
> everybody else. Any developer worth anything is not impaired in
> understanding code bcs tab are used instead of space, or bcs the
> indentation is 2 char instead of 4.

I don't think having official styles is all that much less "imposing" if
they're per file.

> > If you really wouldn't "give a damn" then why would it cause you any
> > problems?
> 
> It mean what it mean. When I work on some file I don't care what style
> it use. But currently I have to care, otherwise auto-indenting is
> unusable, and I might introduce tab in tab-less files, or indent with
> spaces in a tab indented file, etc

So you don't really have anything against a common style yourself, but
think it won't happen because of others.

> > Overall the tag proposal seems to assume the following:
> > 1) Inconsistent indentation _within_ a file is a lot bigger problem
> > than inconsistent indentation between files.
> 
> Definitely, if a file have a consistent style I just have to set it in
> my editor and all is fine. Otherwise I have check and check over: is
> that block using tab or space, damn the editor used tabs instead of
> space to indent that line, etc

Well this sounds like a problem caused by trying to stay consistent with
a different style in each file. If you just add code with 4 space indent
(say with spaces only, no tabs, in case someone cares) I think that
won't really cause problems.

IMO it's somewhat inconsistent to say that "any developer worth
anything" must be able to read whatever indentation style, but then not
except him to cope with others writing the most common style in "his"
files (even if avoiding that would require people to write a style
they're not familiar with anywhere else, which is a much bigger
requirement than reading).

> > So I don't think the goal of consistent indentation style on per-file
> > level is a worthwhile one (consistency on a per-line scale, and
> > consistency between all code you could work on at once could matter
> > more, but a file is not really a relevant unit - parts of a file are
> > about the same as different files). And if the per-file styles should
> > be strictly followed then most files should have a common style,
> > which you seem to oppose.
> 
> As said above I don't like much imposing a single style, but I wouldn't
> oppose it. However my feelings is that this goal can't realistically be
> reached in a reasonable time frame. On the other hand tagging files
> already having a consistent style is easy to do, and would make the
> work of some easier, without changing anything for those that don't
> want to use them.

The problem you're trying to solve seems to be that following varying
per-file styles is hard, and you think adding tags would make following
them easier. I think that goes in the wrong direction in making such
varying styles more official and important to follow. I think the
difficulty of following them is better solved by not following them when
it causes significant extra work. Use 4 space indent and people should
be able to read it even if it doesn't exactly match what is in the rest
of the file.




More information about the MPlayer-dev-eng mailing list