Dealii: Have inline on a separate line

Created on 24 May 2018  路  3Comments  路  Source: dealii/dealii

In https://github.com/dealii/dealii/pull/6656 some people requested to have inline on a separate line.
clang-format seems not to be capable of doing so, but likely accepts when this done some other way.
Should we have a separate script taking care of this?
I prefer to do this after introducing clang-format.

Discussion Miscellaneous

Most helpful comment

I strongly disagree for two reasons:

  • It is hard to get the regular expression right because you have to be context aware. Above perl script fails with the following input:
inline int foo(int ffffffffffffffffffffffffffffffffffffffff_bar,
               int ffffffffffffffffffffffffffffffffffffffff_baz,
               int ffffffffffffffffffffffffffffffffffffffff_bar)
{
  return 0;
}

Output:

int foo(int ffffffffffffffffffffffffffffffffffffffff_bar,
               int ffffffffffffffffffffffffffffffffffffffff_baz,
               int ffffffffffffffffffffffffffffffffffffffff_bar)
{
  return 0;
}
  • We switch to clang-format in order to NOT HAVE regular expression based parsing and mangling of source code (as done by astyle).
  • By just dropping a .clang-format file into the source directory, every IDE and editor that supports clang-format should do the right thing.

If everyone feels so strongly about having inline on a separate line, I suggest we simply wait a year until this is supported by clang-format. Or simply never switch. But PLEASE PLEASE PLEASE not again a set of hand-rolled perl regexs (like astyle) for indenting.

All 3 comments

I've just posted #6661 for this -- easy enough to do this with this sort of perl expression:

perl -pi -e 's/^(\s*)inline\s+(.+)/\1inline\n\1\2/g;' include/deal.II/*/*h

I strongly disagree for two reasons:

  • It is hard to get the regular expression right because you have to be context aware. Above perl script fails with the following input:
inline int foo(int ffffffffffffffffffffffffffffffffffffffff_bar,
               int ffffffffffffffffffffffffffffffffffffffff_baz,
               int ffffffffffffffffffffffffffffffffffffffff_bar)
{
  return 0;
}

Output:

int foo(int ffffffffffffffffffffffffffffffffffffffff_bar,
               int ffffffffffffffffffffffffffffffffffffffff_baz,
               int ffffffffffffffffffffffffffffffffffffffff_bar)
{
  return 0;
}
  • We switch to clang-format in order to NOT HAVE regular expression based parsing and mangling of source code (as done by astyle).
  • By just dropping a .clang-format file into the source directory, every IDE and editor that supports clang-format should do the right thing.

If everyone feels so strongly about having inline on a separate line, I suggest we simply wait a year until this is supported by clang-format. Or simply never switch. But PLEASE PLEASE PLEASE not again a set of hand-rolled perl regexs (like astyle) for indenting.

It looks like @tamiko has good arguments against, closing for now.

Was this page helpful?
0 / 5 - 0 ratings