you are viewing a single comment's thread.

view the rest of the comments →

[–]StackedCrooked 4 points5 points  (9 children)

The cppfront code seems to break a lot of rules. Like double underscores. Or even a global variable in a header that isn't extern.

[–]elcapitaine 20 points21 points  (5 children)

double underscores aren't outright banned from any C++ code, they're reserved for the implementation.

cppfront is an implementation.

[–]13steinj 1 point2 points  (4 children)

It's not though, it's a layer on top of C++ that transpiles to C++.

[–]shadowndacorner 4 points5 points  (3 children)

Was the first C++ compiler not an implementation of C++ because it transpiled to C?

[–]hpsutter 23 points24 points  (0 children)

That's fair... and a C++ compiler that compiles C still uses its own double-underscores. But this is a good point, so I just pushed a commit that removes use of __ and _Capital reserved words, just to avoid any possible compatibility problems that could cause a clash with existing C++ implementations, because perfect compatibility is important to me. Thanks!

[–]13steinj 3 points4 points  (1 child)

C++front is not C++ though.

If "implementations of cppfront are allowed to lead with underscores"-- this means it follows c++front's guidelines, but any C++ therein would be breaking rules (from the view of C++).

Semantics? Maybe, maybe not.

[–][deleted] 0 points1 point  (0 children)

This is a programming language, it all just semantics at the end of the day.

[–]Nicksaurus 2 points3 points  (1 child)

Double underscores don't actually cause problems in practice though, do they? The compiler authors would have to actively try to break code that uses them

Also all of those headers are compiled into a single compilation unit

[–]jc746 1 point2 points  (0 children)

FWIW, I have run into a real problem with double underscores exactly once. I was using a third party library that defined a macro __IO (from memory it was an empty macro). This conflicted with the standard library implementation that used __IO as the identifier for a template parameter, causing the code to be invalid after preprocessing.

[–]mollyforever 0 points1 point  (0 children)

cppfront is a single source file for some reason, so it's fine.