News for hackers. Stuff that matters.
Re:C++ Modules Might Be Dead-On-Arrival by Chabs on Monday January 28, 2019 @12:35AM (#19015506)
C++, as a language, has never cared about the notion of "files". The entire standard is defined as a function of a "Translation Unit", which is an abstract notion that we tend to associate with "a single .cpp file" by nothing but convention.

Since modules operate at the language level, they need to operate on this notion, which precludes importing by file.

Re:C++ Modules Might Be Dead-On-Arrival by brianberns on Monday January 28, 2019 @12:51AM (#19015553)
But a header is a file, no? And it is referenced explicitly by its file name.
Re:C++ Modules Might Be Dead-On-Arrival by gmueckl on Monday January 28, 2019 @01:16AM (#19015611)
No, the language of the standard carefully omits talking about files. This is because there are still ancient mainframe operating systems around that do not have typical hierarchical filesystems, but it is still technically possible to provide a C++ implementation for these. Prescribing a module name to file name mapping woukd not work in these environments either. This is also why #pragma once was rejected and the replacement #once [unique ID] was invented instead: just defining what is and isn't the same file for #pragma once turned out too difficult to define.
Re:C++ Modules Might Be Dead-On-Arrival by ahaferburg on Monday January 28, 2019 @08:13AM (#19017148)
What I don't get though is why these ancient mainframes need the latest version of the standard. I can't imagine the compiler writers for these OSs to be too eager implement any change at all. You said "technically possible", are you implying that nobody actually does? What are these OSs?

To me this seems like a weird take on accessibility. In order to accommodate that one OS that has some serious disabilities, everyone else has to suffer the consequences. Why not build a ramp for that one OS, and build stairs for everyone else?

Re:C++ Modules Might Be Dead-On-Arrival by gpderetta on Monday January 28, 2019 @08:16PM (#19022830)
IBM has multiple people in the standard committee and they care a lot for both backward compatibility and new standards. They alone were strongly opposed from removing trigraphs from the standard.

Still trigraphs were removed in the end; if there is enough support the committee is willing to break backward compatibility.

Re:C++ Modules Might Be Dead-On-Arrival by simias on Monday January 28, 2019 @08:20AM (#19017190)
>just defining what is and isn't the same file for #pragma once turned out too difficult to define.

Admittedly that's not just a problem with old mainframes. Any system supporting file aliases (be it hardlinks, symlinks or the same FS mounted at several locations for instance) would be tricky to handle.

I always thought #pragma once was a bad idea for that reason, header guards with unique IDs don't require any compiler magic and are simple to reason about without having to read the standard or compiler's docs to figure out how it operates.

Re:C++ Modules Might Be Dead-On-Arrival by Chabs on Monday January 28, 2019 @12:55AM (#19015560)
That's handled by the preprocessor. It's literally just a "insert the contents of that file here" copy-paste.
Re:C++ Modules Might Be Dead-On-Arrival by haberman on Monday January 28, 2019 @01:29AM (#19015642)
But the preprocessor is part of the C++ standard, no? I'm really not seeing why it's ok for the preprocessor to refer to files but not the language.

Also, going to this level of trouble to support systems that don't have files seems... odd. Targets that don't have files, that I can totally understand. But compiler toolchains that don't have the notion of a file? That sounds obscure beyond obscure. I'm surprised such a system would be a compilation host instead of a cross-compile target.

Re:C++ Modules Might Be Dead-On-Arrival by Chabs on Monday January 28, 2019 @01:40AM (#19015680)
We are talking about a language that goes so far as to make sure it functions on systems where the size of a byte is not 8, or where memory is not necessarily linearly addressed. People tend to forget how shockingly flexible standard-compliant C++ code actually is.
Re:C++ Modules Might Be Dead-On-Arrival by haberman on Monday January 28, 2019 @01:57AM (#19015722)
I get that, but there's also precedent for cutting ancient things loose. Both C and C++ have finally decided to specify that signed integers are two's complement: https://twitter.com/jfbastien/status/989242576598327296?lang... Also trigraphs are gone in C++17.
Re:C++ Modules Might Be Dead-On-Arrival by gardaani on Monday January 28, 2019 @05:48AM (#19016462)
This C++ code actually compiles with clang++. Incredible!

    int main(int argc, char *argv<::>)
    <%
        if (argc not_eq 1 and argc not_eq 2) <% return 1; %>
        return 0;
    %>
https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C
Re:C++ Modules Might Be Dead-On-Arrival by bregma on Monday January 28, 2019 @09:07AM (#19017478)
Digraphs are still a part of the language. I would be more surprised if a conformant piece of code did not compile with a conformant compiler.
Re:C++ Modules Might Be Dead-On-Arrival by pjmlp on Monday January 28, 2019 @03:35AM (#19016003)
Trigraphs are gone, but it took a while to win IBM representatives over it
Re:C++ Modules Might Be Dead-On-Arrival by favorited on Monday January 28, 2019 @02:58PM (#19020526)
I don't think they were ever really won over, I think their concerns were heard and they begrudgingly acquiesced rather than vote down C++17.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n421...