|
|
4 yıl önce | |
|---|---|---|
| .. | ||
| README.md | 48d5b18026 Initial rough framework for specification. (#140) | 4 yıl önce |
| execution.md | 48d5b18026 Initial rough framework for specification. (#140) | 4 yıl önce |
| lex.md | 48d5b18026 Initial rough framework for specification. (#140) | 4 yıl önce |
| libs.md | 48d5b18026 Initial rough framework for specification. (#140) | 4 yıl önce |
| names.md | 48d5b18026 Initial rough framework for specification. (#140) | 4 yıl önce |
| parsing.md | 48d5b18026 Initial rough framework for specification. (#140) | 4 yıl önce |
| semantics.md | 48d5b18026 Initial rough framework for specification. (#140) | 4 yıl önce |
A program is a collection of one or more linkage units that are linked together.
A Carbon linkage unit is the result of translating a source file. A foreign linkage unit is an artifact produced by a translation process for some other programming language. A linkage unit is either a Carbon linkage unit or a foreign linkage unit.
A source file is a sequence of Unicode code points.
Note: Source files are typically stored on disk in files with a
.carbonfile extension, encoded in UTF-8.
A program is valid if it contains no constructs that violate "shall" constraints in this specification. Otherwise, the program is invalid.
An implementation is conforming if it accepts all valid programs, it rejects all invalid programs for which a diagnostic is required, and the execution semantics of all accepted programs is as specified in this specification.
Translation of a source file into a Carbon linkage unit proceeds as follows:
Note: After semantic analysis, an implementation may optionally monomorphize generics by a process similar to template instantiation.
The resulting linkage unit comprises all entities in the translated source file that are either external or are reachable from an external entity.
Note: A linkage unit can include non-monomorphized generics, but never includes templates. Constant evaluation can eliminate references to entities.
Two declarations declare the same entity if both declarations are in the same library and the same scope and declare the same name.
TODO: Linkage rules for foreign entities. TODO: Ability to declare file-local entities.
All declarations of an entity shall use the same type.
Every entity that is reachable from a linkage unit in a program shall be defined by a linkage unit in the program; no diagnostic is required unless an entity that can be referenced during the execution of the program is not defined.
There shall not be more than one definition of an entity in a program.