@@ -6,7 +6,22 @@ $(HEADERNAV_TOC)
66
77$(P Editions provide a way to evolve D by obsoleting
88features while maintaining compatibility with code that uses those
9- features.
9+ features. Editions are a module level feature, i.e. various sections
10+ of a module cannot be set to different editions.
11+ )
12+
13+ $(P The edition is set by default, by putting it in the $(GLINK2 module, ModuleDeclartion),
14+ or with the $(TT -edition) command line switch.
15+ )
16+
17+ $(P
18+ Editions are meant to be backwards and forwards compatible; it makes possible a D
19+ module targeting one edition to import a D module targeting any other edition.
20+ A template must obey the rules of the edition targeted by the module in which it
21+ is defined, not the module in which it is instantiated. Compatibility is at the
22+ source code level; no promises of ABI compatibility are made. All code, old and
23+ new, must be compiled with the same version of the compiler. Only one version
24+ of DRuntime, which must support all existing editions, is to be provided with a compiler release.
1025)
1126
1227$(H2 $(LNAME2 grammar, Grammar))
@@ -16,6 +31,52 @@ $(GNAME Edition):
1631 $(GLINK2 lex, DecimalInteger)
1732)
1833
34+ $(H2 WWhat can editions do?)
35+
36+ $(UL
37+ $(LI Deleting existing features -
38+ This would be the easiest change that could be made in an edition,
39+ since it would forbid future code from using deprecated features.
40+ Aside from maintaining the compiler for those features, there would be no impact.)
41+
42+ $(LI Adding new features -
43+ Editions are not necessary for adding new features that are purely additive,
44+ i.e., that do not interact with existing features. Editions may backport
45+ them to previous editions where possible.)
46+
47+ $(LI Changing defaults -
48+ Defaults matter because they encourage and influence behavior. Newer editions
49+ could change defaults such as $(TT @system) / $(TT @safe) and others.)
50+
51+ $(LI Changing semantics -
52+ An edition could make it so that:
53+
54+ ```
55+ shared int i;
56+ i += 5;
57+ ```
58+
59+ $(P would be lowered to:)
60+
61+ ```
62+ shared int i;
63+ i.atomicOp!"+="(1);
64+ ```
65+ )
66+ )
67+
68+ $(H2 Specifying the Edition)
69+
70+ $(P An edition level is determined by:)
71+
72+ $(OL
73+ $(LI an explicit 4 digit number corresponding to the year in which the desired edition was released)
74+ $(LI if no edition is specified, and there is no $(GLINK2 ModuleDeclaration) in the source code,
75+ the edition used is the $(B Baseline Edition), which corresponds to 2023.)
76+ $(LI if no edition is specified, and there is a $(GLINK2 ModuleDeclaration) in the source code,
77+ the edition used is the year the compiler was released.)
78+ )
79+
1980$(SPEC_SUBNAV_PREV legacy, Legacy Code)
2081
2182)
0 commit comments