@@ -9,7 +9,7 @@ type = "docs"
99Protobuf Editions replace the proto2 and proto3 designations that we have used
1010for Protocol Buffers. Instead of adding ` syntax = "proto2" ` or `syntax =
1111"proto3"` at the top of proto definition files, you use an edition number, such
12- as ` edition = "2024 " ` , to specify the default behaviors your file will have.
12+ as ` edition = "2023 " ` , to specify the default behaviors your file will have.
1313Editions enable the language to evolve incrementally over time.
1414
1515Instead of the hardcoded behaviors that older versions have had, editions
@@ -22,6 +22,8 @@ the default behavior for the edition you've selected. You can also override your
2222overrides. The [ section later in this topic on lexical scoping] ( #scoping ) goes
2323into more detail on that.
2424
25+ * The latest released edition is 2023.*
26+
2527## Lifecycle of a Feature {#lifecycles}
2628
2729Editions provide the fundamental increments for the lifecycle of a feature.
@@ -93,6 +95,8 @@ Prototiller tool to change the definition files to use Protobuf Editions syntax.
9395// proto2 file
9496syntax = "proto2";
9597
98+ package com.example;
99+
96100message Player {
97101 // in proto2, optional fields have explicit presence
98102 optional string name = 1;
@@ -110,6 +114,8 @@ message Player {
110114
111115 // in proto2 enums are closed
112116 optional Handed handed = 4;
117+
118+ reserved "gender";
113119}
114120```
115121
@@ -119,6 +125,8 @@ message Player {
119125// Edition version of proto2 file
120126edition = "2023";
121127
128+ package com.example;
129+
122130message Player {
123131 // fields have explicit presence, so no explicit setting needed
124132 string name = 1;
@@ -137,6 +145,8 @@ message Player {
137145 }
138146
139147 Handed handed = 4;
148+
149+ reserved gender;
140150}
141151```
142152
@@ -155,6 +165,8 @@ Prototiller tool to change the definition files to use Protobuf Editions syntax.
155165// proto3 file
156166syntax = "proto3";
157167
168+ package com.example;
169+
158170message Player {
159171 // in proto3, optional fields have explicit presence
160172 optional string name = 1;
@@ -172,6 +184,8 @@ message Player {
172184
173185 // in proto3 enums are open
174186 optional Handed handed = 4;
187+
188+ reserved "gender";
175189}
176190```
177191
@@ -181,6 +195,8 @@ message Player {
181195// Editions version of proto3 file
182196edition = "2023";
183197
198+ package com.example;
199+
184200message Player {
185201 // fields have explicit presence, so no explicit setting needed
186202 string name = 1;
@@ -197,6 +213,8 @@ message Player {
197213 }
198214
199215 Handed handed = 4;
216+
217+ reserved gender;
200218}
201219```
202220
@@ -229,16 +247,16 @@ message Person {
229247 int32 id = 2 [features.presence = IMPLICIT];
230248
231249 enum Pay_Type {
232- PAY_TYPE_UNSPECIFIED = 1,
233- PAY_TYPE_SALARY = 2,
234- PAY_TYPE_HOURLY = 3
250+ PAY_TYPE_UNSPECIFIED = 1;
251+ PAY_TYPE_SALARY = 2;
252+ PAY_TYPE_HOURLY = 3;
235253 }
236254
237255 enum Employment {
238256 option features.enum_type = OPEN;
239- EMPLOYMENT_UNSPECIFIED = 0,
240- EMPLOYMENT_FULLTIME = 1,
241- EMPLOYMENT_PARTTIME = 2,
257+ EMPLOYMENT_UNSPECIFIED = 0;
258+ EMPLOYMENT_FULLTIME = 1;
259+ EMPLOYMENT_PARTTIME = 2;
242260 }
243261 Employment employment = 4;
244262}
@@ -270,9 +288,9 @@ definition files, and vice versa:
270288syntax = "proto2";
271289
272290enum Employment {
273- EMPLOYMENT_UNSPECIFIED = 0,
274- EMPLOYMENT_FULLTIME = 1,
275- EMPLOYMENT_PARTTIME = 2,
291+ EMPLOYMENT_UNSPECIFIED = 0;
292+ EMPLOYMENT_FULLTIME = 1;
293+ EMPLOYMENT_PARTTIME = 2;
276294}
277295```
278296
0 commit comments