No, sorry. I find

double x[][] = {
  { 1.12345 }
}

to be more readable than

double x[][] =
  { { 1.12345 } } 

I think we're in agreement, carry on!


On May 17, 2013, at 9:17 , Daniel Jasper <[email protected]> wrote:

> Just to be sure, you would find
> 
> double x[][] = { {
>   1.12345
> } }
> 
> More readable than
> 
> double x[][] = {
>   { 1.12345 }
> }
> 
> ?
> 
> I am just asking because I don't agree at all :-). Especially if you start 
> adding elements:
> 
> double x[][] = {
>   { 1.12345 }, { 1.12345 }, ...
> }
> 
> As mentioned in the change description, this change basically does not modify 
> the behavior (except in some very rare edge case). Your example would have 
> been formatted identically before and after the change. However, we are 
> currently investigating how to get some kind of consistency into all the 
> different formattings that can now be created with C++11's braced-init-lists. 
> Once we have a reasonably complete proposal, I will post that somewhere.
> 
> 
> On Fri, May 17, 2013 at 6:09 PM, Jordan Rose <[email protected]> wrote:
> Yeah, I actually find
> 
> double x[] = {
>         1.12345
> }
> 
> to be more readable than
> 
> double x[] =
>         { 1.12345 }
> 
> and I feel like that last example is basically the same.
> 
> 
> On May 17, 2013, at 2:35 , Daniel Jasper <[email protected]> wrote:
> 
> > Author: djasper
> > Date: Fri May 17 04:35:01 2013
> > New Revision: 182082
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=182082&view=rev
> > Log:
> > Slightly modify the formatting rules for braced lists.
> >
> > Basically, the new rule is: The opening "{" always has to be on the
> > same line as the first element if the braced list is nested
> > (e.g. in another braced list or in a function).
> >
> > The solution that clang-format produces almost always adheres to this
> > rule anyway and this makes clang-format significantly faster for larger
> > lists. Added a test cases for the only exception I could find
> > (which doesn't seem to be very important at first sight).
> >
> > Modified:
> >    cfe/trunk/lib/Format/Format.cpp
> >    cfe/trunk/unittests/Format/FormatTest.cpp
> >
> > Modified: cfe/trunk/lib/Format/Format.cpp
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=182082&r1=182081&r2=182082&view=diff
> > ==============================================================================
> > --- cfe/trunk/lib/Format/Format.cpp (original)
> > +++ cfe/trunk/lib/Format/Format.cpp Fri May 17 04:35:01 2013
> > @@ -977,10 +977,18 @@ private:
> >
> >   /// \brief Returns \c true, if a line break after \p State is allowed.
> >   bool canBreak(const LineState &State) {
> > -    if (!State.NextToken->CanBreakBefore &&
> > -        !(State.NextToken->is(tok::r_brace) &&
> > +    const AnnotatedToken &Current = *State.NextToken;
> > +    const AnnotatedToken &Previous = *Current.Parent;
> > +    if (!Current.CanBreakBefore &&
> > +        !(Current.is(tok::r_brace) &&
> >           State.Stack.back().BreakBeforeClosingBrace))
> >       return false;
> > +    // The opening "{" of a braced list has to be on the same line as the 
> > first
> > +    // element if it is nested in another braced init list or function 
> > call.
> > +    if (!Current.MustBreakBefore && Previous.is(tok::l_brace) &&
> > +        Previous.Parent &&
> > +        Previous.Parent->isOneOf(tok::l_brace, tok::l_paren, tok::comma))
> > +      return false;
> >     return !State.Stack.back().NoLineBreak;
> >   }
> >
> >
> > Modified: cfe/trunk/unittests/Format/FormatTest.cpp
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=182082&r1=182081&r2=182082&view=diff
> > ==============================================================================
> > --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
> > +++ cfe/trunk/unittests/Format/FormatTest.cpp Fri May 17 04:35:01 2013
> > @@ -1192,6 +1192,18 @@ TEST_F(FormatTest, StaticInitializers) {
> >       "static SomeClass = { a, b, c, d, e, f, g, h, i, j,\n"
> >       "                     looooooooooooooooooooooooooooooooooongname,\n"
> >       "                     looooooooooooooooooooooooooooooong };");
> > +  // Here, everything other than the "}" would fit on a line.
> > +  verifyFormat("static int LooooooooooooooooooooooooongVariable[1] = {\n"
> > +               "  100000000000000000000000\n"
> > +               "};");
> > +
> > +  // FIXME: This would fit into the column limit if we'd fit "{ {" on the 
> > first
> > +  // line. However, the formatting looks a bit off and this probably 
> > doesn't
> > +  // happen often in practice.
> > +  verifyFormat("static int Variable[1] = {\n"
> > +               "  { 1000000000000000000000000000000000000 }\n"
> > +               "};",
> > +               getLLVMStyleWithColumns(40));
> > }
> >
> > TEST_F(FormatTest, NestedStaticInitializers) {
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > [email protected]
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 
> 

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to