| ... | ... | @@ -536,7 +536,7 @@ const Timestamp = struct { |
| 536 | 536 | {#header_close#} |
| 537 | 537 | {#header_open|Top-Level Doc Comments#} |
| 538 | 538 | <p>User documentation that doesn't belong to whatever |
| 539 | | immediately follows it, like container-level documentation, goes |
| 539 | immediately follows it, like {#link|container|Containers#}-level documentation, goes |
| 540 | 540 | in top-level doc comments. A top-level doc comment is one that |
| 541 | 541 | begins with two slashes and an exclamation point: |
| 542 | 542 | {#syntax#}//!{#endsyntax#}.</p> |
| ... | ... | @@ -1080,7 +1080,7 @@ fn addOne(number: i32) i32 { |
| 1080 | 1080 | <p> |
| 1081 | 1081 | When the <kbd>zig test</kbd> tool is building a test runner, only resolved {#syntax#}test{#endsyntax#} |
| 1082 | 1082 | declarations are included in the build. Initially, only the given Zig source file's top-level |
| 1083 | | declarations are resolved. Unless nested containers are referenced from a top-level test declaration, |
| 1083 | declarations are resolved. Unless nested {#link|containers|Containers#} are referenced from a top-level test declaration, |
| 1084 | 1084 | nested container tests will not be resolved. |
| 1085 | 1085 | </p> |
| 1086 | 1086 | <p> |
| ... | ... | @@ -1328,7 +1328,7 @@ const color: Color = .@"really red"; |
| 1328 | 1328 | |
| 1329 | 1329 | {#header_open|Container Level Variables#} |
| 1330 | 1330 | <p> |
| 1331 | | Container level variables have static lifetime and are order-independent and lazily analyzed. |
| 1331 | {#link|Container|Containers#} level variables have static lifetime and are order-independent and lazily analyzed. |
| 1332 | 1332 | The initialization value of container level variables is implicitly |
| 1333 | 1333 | {#link|comptime#}. If a container level variable is {#syntax#}const{#endsyntax#} then its value is |
| 1334 | 1334 | {#syntax#}comptime{#endsyntax#}-known, otherwise it is runtime-known. |
| ... | ... | @@ -1350,7 +1350,7 @@ const std = @import("std"); |
| 1350 | 1350 | const expect = std.testing.expect; |
| 1351 | 1351 | {#code_end#} |
| 1352 | 1352 | <p> |
| 1353 | | Container level variables may be declared inside a {#link|struct#}, {#link|union#}, or {#link|enum#}: |
| 1353 | Container level variables may be declared inside a {#link|struct#}, {#link|union#}, {#link|enum#}, or {#link|opaque#}: |
| 1354 | 1354 | </p> |
| 1355 | 1355 | {#code_begin|test|namespaced_container_level_variable#} |
| 1356 | 1356 | const std = @import("std"); |
| ... | ... | @@ -7066,7 +7066,7 @@ test "fibonacci" { |
| 7066 | 7066 | {#code_end#} |
| 7067 | 7067 | |
| 7068 | 7068 | <p> |
| 7069 | | At container level (outside of any function), all expressions are implicitly |
| 7069 | At {#link|container|Containers#} level (outside of any function), all expressions are implicitly |
| 7070 | 7070 | {#syntax#}comptime{#endsyntax#} expressions. This means that we can use functions to |
| 7071 | 7071 | initialize complex static data. For example: |
| 7072 | 7072 | </p> |
| ... | ... | @@ -7538,7 +7538,7 @@ volatile ( |
| 7538 | 7538 | |
| 7539 | 7539 | {#header_open|Global Assembly#} |
| 7540 | 7540 | <p> |
| 7541 | | When an assembly expression occurs in a container level {#link|comptime#} block, this is |
| 7541 | When an assembly expression occurs in a {#link|container|Containers#} level {#link|comptime#} block, this is |
| 7542 | 7542 | <strong>global assembly</strong>. |
| 7543 | 7543 | </p> |
| 7544 | 7544 | <p> |
| ... | ... | @@ -8843,7 +8843,7 @@ fn func() void { |
| 8843 | 8843 | {#header_open|@hasDecl#} |
| 8844 | 8844 | <pre>{#syntax#}@hasDecl(comptime Container: type, comptime name: []const u8) bool{#endsyntax#}</pre> |
| 8845 | 8845 | <p> |
| 8846 | | Returns whether or not a {#link|struct#}, {#link|enum#}, or {#link|union#} has a declaration |
| 8846 | Returns whether or not a {#link|container|Containers#} has a declaration |
| 8847 | 8847 | matching {#syntax#}name{#endsyntax#}. |
| 8848 | 8848 | </p> |
| 8849 | 8849 | {#code_begin|test|hasDecl#} |
| ... | ... | @@ -12436,6 +12436,19 @@ fn readU32Be() u32 {} |
| 12436 | 12436 | </div> |
| 12437 | 12437 | {#header_close#} |
| 12438 | 12438 | |
| 12439 | {#header_open|Appendix#} |
| 12440 | {#header_open|Containers#} |
| 12441 | <p> |
| 12442 | A <em>container</em> in Zig is any syntactical construct that acts as a namespace to hold {#link|variable|Container Level Variables#} and {#link|function|Functions#} declarations. |
| 12443 | Containers are also type definitions which can be instantiated. |
| 12444 | {#link|Structs|struct#}, {#link|enums|enum#}, {#link|unions|union#}, {#link|opaques|opaque#}, and even Zig source files themselves are containers. |
| 12445 | </p> |
| 12446 | <p> |
| 12447 | Although containers (except Zig source files) use curly braces to surround their definition, they should not be confused with {#link|blocks|Blocks#} or functions. |
| 12448 | Containers do not contain statements. |
| 12449 | </p> |
| 12450 | {#header_close#} |
| 12451 | |
| 12439 | 12452 | {#header_open|Grammar#} |
| 12440 | 12453 | {#syntax_block|peg|grammar.y#}Root <- skip container_doc_comment? ContainerMembers eof |
| 12441 | 12454 | |
| ... | ... | @@ -13001,6 +13014,7 @@ keyword <- KEYWORD_align / KEYWORD_allowzero / KEYWORD_and / KEYWORD_anyframe |
| 13001 | 13014 | <li>Together we serve the users.</li> |
| 13002 | 13015 | </ul> |
| 13003 | 13016 | {#header_close#} |
| 13017 | {#header_close#} |
| 13004 | 13018 | </main></div> |
| 13005 | 13019 | </div> |
| 13006 | 13020 | </body> |