Skip to content

Conversation

danakj
Copy link
Contributor

@danakj danakj commented Sep 9, 2025

We propose a principle that it's always possible to concat together Carbon source files without changing the meaning of or diagnostics applied to the code.

@danakj danakj requested a review from josh11b September 9, 2025 13:24
@github-actions github-actions bot added the documentation An issue or proposed change to our documentation label Sep 9, 2025
@github-actions github-actions bot requested a review from chandlerc September 9, 2025 13:24
Comment on lines +41 to +42
Carbon uses syntax to denote the start of a library or package, which functions
at the top of a file or in the middle of a file in the same way. Language rules
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really true. You are only allowed to put the header lines before other declarations, and only once. I think the idea should be closer to saying that there should be a purely mechanical process for combining two files.

Comment on lines +33 to +34
code in either file. It will be required to order the concatenation so that
dependencies are ordered first, in order to maintain the information
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may be worth saying a bit more about imports. Can adding imports lead to ambiguities that create diagnostics?

Comment on lines +35 to +37
accumulation principle. There is always an ordering that allows any Carbon
project to be fully concatenated into a single Carbon source file and thus built
with a single compiler invocation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have a plan to support multiple packages in a single file.

recreate and distribute a bug repro or to build a piece of C++ code in an
environment without the requirement of a build system. This allows code taken
from any build environment to be easily compiled by a developer in any other
environment, through a single compiler invocation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also mention minimization?

danakj and others added 4 commits September 9, 2025 11:26
Co-authored-by: josh11b <[email protected]>
Co-authored-by: josh11b <[email protected]>
Co-authored-by: Carbon Infra Bot <[email protected]>
Co-authored-by: Carbon Infra Bot <[email protected]>
project to be fully concatenated into a single Carbon source file and thus built
with a single compiler invocation.

## Applications of these principles
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add something about the example that led us to forming the principle?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation An issue or proposed change to our documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants