When there is no package directive, default to Main//default api instead of
Main//default impl. This has two user-visible consequences:
.carbon, not .impl.carbon.Main//default api is allowed.Code and name organization says:
.carbon extension. They must not have a
.impl.carbon extension..impl.carbon extension.The Main//default library is currently specified as an impl file. This means
that it should be something like main.impl.carbon.
More generally in Carbon, a single-file library can be an api file, not an
impl file. This comes as a side-effect from impl files implicitly importing
the api, which would fail if there were an impl file without an api. On
the other hand, there is no requirement that an api file have an impl.
Proposal
#2550: Simplified package declaration for the Main package
chose impl as the default, providing an empty api file that cannot otherwise
be imported. The proposal doesn't provide rationale for this choice; it likely
wasn't considered key to the proposal.
In C++, we often see main.cpp. This might be where the impl choice for
Main//default comes from, as it has a more equivalent feel.
Omitting the package directive means Main//default api, rather than impl. As
a consequence:
.carbon extension applies instead of the .impl.carbon extension.api can only be defined once, so there is a limit of one such file per
executable.Mentions of Main//default api as being an empty file are removed.
The rules preventing use of Main//default in package, library, or import
remain. The library can only be defined by omission of package and library,
and cannot be imported.
Code that is easy to read, understand, and write
Run logic in a main.carbon file is expected to be more
intuitive than main.impl.carbon.Main//default impl instead of Main//default apiMain//default impl, the status quo, is now a declined alternative. Key
considerations are:
Main//default api is consistent with single-file libraries in other
contexts.main.carbon is preferred over main.impl.carbon, and using
Main//default api allows the main.carbon extension without
special-casing the file extension choices.Main//default api as an empty file is no
longer needed.Main//default impl files is of limited
utility. Run could only be defined in one such file, and the
Main//default api was defined as empty so no sharing was allowed.