Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> GSG prohibits the use of static definitions and annonymous namespaces in header files. How else do we declare constants?

Uhm… what?

1) I would challenge the author to produce any useful use of anonymous namespaces in header files that doesn't violate ODR. I'd also challenge them to not break ODR with constants in header files in the way they seem to mean.

I should add: without UB, plz.

2) How else do we declare constants? Uhm, how about: extern const int foo; or just "inline constexpr int foo = 1" in header but non-static and not in anonymous namespace?

> Globals like this are not problematic and very useful: [example of nontrivially destructible global]

It doesn't look dangerous, but allowing it does not scale to a billion lines of code. Code easier to reason about is less buggy code.

In general though: Author spends 1 SWE-year per year on coding, Google spends what, 100 SWE-millenia per year? It's optimizing for that use case.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: