What I teach about modules is compelling. Programmers like and want to use it.
However, they ask how they should organize module files in practice.

So far I cannot recommend a specific suffix (and I might never be able to do that).
However there is one important question that IMO the standard should answer:
Do we need different suffixes?

I understand that a suffix discussion is only of practical value.
But IMO the standard has to give an answer here (which has nothing to do with which suffixes are used).

Let me elaborate that in detail:

Not having a standard suffix has interesting consequences.
So far we have header files and translation units.
But once we know what a C++ translation unit is, we can just compile them all with the same compiler options or commands. Because in practice we have different suffixes for header and source files, we can set-up generic rules to compile our code.

This works for any suffix, provided you know the way to tell the compiler that we have a C++ file here:
(use /Tp with VC++ and -xc++ with gcc and you are done).

Is this still true with modules?
That is: Can we expect that identifying a file as C++ file is enough to be able to (pre) compile it as C++ file?

Current compilers give different answers (AFAIK):

- gcc says the same suffix is possible. There is not special option for modules.
I can still have my own suffixes and use -xc++ though.

- VC++ currently requires different suffixes or different command-line arguments.
Identifying a file as C++ file is not enough.
For example
  - This is not enough:  /Tp mymod.cppm
  - You need: /interface /Tp mymod.cppm

I wonder whether the behavior of VC++ is standard conforming.

I see no place in the C++ standard saying that there has to be different treatment of C++ source files to make them work.
Or do we require this somewhere?
We do not require different treatment just because we have templates, namespaces, or exceptions used inside.
Therefore, I would expect that also using modules does not require special handling.
(This is independent from the question whether different suffixes help to deal with these files).

If I am right, VC++ is not standard conforming.


In any case it would help a lot to clarify:
Can all C++ source files expect that treating them the same way works fine?

If not, we obviously need different suffixes. But then we should clearly say so (without necessarily saying which suffix it is).


I hope this questions brings us a bit forward to be able teach the first portable "hello, modules" example.

Thanks

  Nico

-- 
--- 
Nicolai M. Josuttis
www.josuttis.de
+49 (0)531 / 129 88 86
+49 (0)700 / JOSUTTIS

Books:
 C++: http://cppstd20.com, http://cppstd17.com, http://cppmove.com,
      http://cppstdlib.com, http://tmplbook.com