[MPlayer-dev-eng] Indentation style (was: [PATCH] Fix useless dependencies in the stream lib)
Alban Bedel
albeu at free.fr
Wed Apr 9 02:49:18 CEST 2008
On Wed, 09 Apr 2008 01:48:53 +0300
Uoti Urpala <uoti.urpala at pp1.inet.fi> wrote:
> On Tue, 2008-04-08 at 23:37 +0200, Alban Bedel wrote:
> > On Tue, 08 Apr 2008 23:11:02 +0300
> > Uoti Urpala <uoti.urpala at pp1.inet.fi> wrote:
> > > I think letting "the maintainer" decide on use of non-standard
> > > tags is a major problem with your proposal. The maintainer list
> > > often does
>
> > Maintainer was meant in the broadest possible sense. You are making
> > things a lot more complex than they need to be. Tags should
> > obviously be handled just like the rest of the code in the file.
>
> 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. 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.
> > > If some file which uses non-standard formatting (especially other
> > > than 4 space indent) gets many edits with 4-space indent then is
> > > setting tags really the right answer? IMO it's questionable
> > > whether it would be reasonable to set nonstandard tags, as
> > > obviously more people than the original author need to work on
> > > it. Maybe reindenting it to follow a common style would be a
> > > better choice.
> >
> > Obviously tags can't be applied to files with mixed indentation. If
> > and how we reindent files needing it is a different topic.
> > IMHO files with just a few inconsistent part should be fixed to
> > follow the rest and wild mixture should use an agreed style (I
> > don't care which as long as there is tags ;)
>
> 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?
> 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.
> > > One example of a file which IMO should not require using
> > > nonstandard style for edits is m_option.c. You originally wrote
> > > that file, but working on options related to other code can
> > > easily require changes to it, and it should not be considered
> > > anyone's "own" file.
> >
> > This is again unrelated to the fact that files are tagged or not.
> > Tags are only useful for files with a consistent indenting to help
> > keeping it consistent. You are still free to reindent it (and
> > accordingly update the tags ;) if you want/need to.
>
> 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.
> 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.
> > > That there are files with mixed style shows that in practice many
> > > files will be worked on by several people, at the same time or at
> > > different times. Allowing the first person to work on the file to
> > > set nonstandard tags and making such a style even more "official"
> > > for the file would have a negative effect. Changing style every
> > > few lines is a readability problem, but for example having some
> > > 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?
> > 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.
> > Then ppl
> > used editors with widely different settings and messed up things; in
> > some places beyond recognition.
>
> I think most of the really bad indentation cases in MPlayer were
> actually produced as a result of people avoiding cosmetic changes, not
> as a result of different styles. I'm not sure which places you're
> referring to, but the "beyond recognition" messed up places I remember
> don't seem like a problem with varying styles (at least not a mix of
> any by themselves reasonable styles; if someone writes code with no
> indentation that style is a problem in itself).
I agree that the no-cosmetic rule is a big factor too.
> > The problem is not that we have devs
> > using aberrant styles, it's the mixture of badly configured editors.
>
> I don't really agree, but since you don't specify what effects exactly
> you consider a problem it's hard to say in detail what specifics I'd
> disagree with.
For me the tab vs space things is the most annoying by far. Broken
indentation come after that, but as you pointed out no-cosmetic is more
to blame on that one.
> > 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.
> 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
> 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
> 2) People should be more strongly required to change their style
> depending on which file they are editing.
Again, personally, I don't care how it look from one file to another.
If you manage to get a common style accepted that's fine with me, if
not I couldn't care less.
> I don't really agree with either of those. You rarely only look in one
> file when making changes, and so having differently indented functions
> in different parts of one file doesn't much differ from having
> differently indented functions in different files.
True, but unless your editor include some quiet advanced stuff,
automatically making out different indent style within the same file
will be quiet hairy.
> I don't have much problem reading differently indented code,
I doubt any dev worth something have problems with this.
> but trying to write code in varying styles (even if the editor handles
> indentation) is much more distracting.
Exactly my point, and why I would like to stop having to mess with my
editor's config and replace spaces with tabs so often.
> 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.
Albeu
More information about the MPlayer-dev-eng
mailing list