Re:Clang Format Tanks Performance
by TwoBit on Tuesday November 19, 2019 @11:54PM
(#21581196)
That reordering is simply a feature of clang-format. Some coding standards require sorting includes alphabetically, possibly to avoid dupes and to make all include usage identical between source files.
[ Parent
| on HN ]
In terms of C/C++ headers, that's like requiring all scopes have their expressions alphanumerically sorted.
C/C++ headers are literal code-injection mechanisms; they aren't modifying a runtime environment by importing symbols, they inject code into the compilation unit.
> Some coding standards require sorting includes alphabetically
Those are some pretty dumb coding standards if that's true.
(I mean, yeah, the original fault is with the C preprocessor and the fact that header order matters, but since we're stuck with that, having those kinds of coding standards is pretty darn silly!)
Re:Clang Format Tanks Performance
by antoinealb on Wednesday November 20, 2019 @08:24AM
(#21583658)
Well given that the order of the headers matter, wouldn't it make sense to have the coding standard specify one true include order ? That's the only way to have a deterministic result.
That ties namespacing to performance, which just sounds horrible to deal with.
Re:Clang Format Tanks Performance
by antoinealb on Wednesday November 20, 2019 @10:58AM
(#21584972)
Of course, the bug is horrible. But given that those type of bugs exist, having a fixed ordering of include statements seem like the least painful way to go.
Indeed, and one reason I dislike sorting header includes alphanumerically is that it makes it easy for include-order-dependencies between them to creep in, as they're always used in the same relative order.