authorgravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-04-27 23:23:13-06:00
committergravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-04-28 00:02:14-06:00
log2ef0795bfb440671bffd3c6b93603c012d27c24d
tree32f25393c954a3c0f0a792da9517ba12cbcb8ea9
parent17e41f6cd36f9b086036b445c0f6cd4bfc576b9d
signaturelock-open Commit is signed but in an unrecognized format.

Update language reference for recent @Type changes


1 files changed, 30 insertions(+), 32 deletions(-)

doc/langref.html.in+30-32
...@@ -1885,7 +1885,7 @@ test "null terminated array" {...@@ -1885,7 +1885,7 @@ test "null terminated array" {
1885 <li>Supports slice syntax: {#syntax#}ptr[start..end]{#endsyntax#}</li>1885 <li>Supports slice syntax: {#syntax#}ptr[start..end]{#endsyntax#}</li>
1886 <li>Supports pointer arithmetic: {#syntax#}ptr + x{#endsyntax#}, {#syntax#}ptr - x{#endsyntax#}</li>1886 <li>Supports pointer arithmetic: {#syntax#}ptr + x{#endsyntax#}, {#syntax#}ptr - x{#endsyntax#}</li>
1887 <li>{#syntax#}T{#endsyntax#} must have a known size, which means that it cannot be1887 <li>{#syntax#}T{#endsyntax#} must have a known size, which means that it cannot be
1888 {#syntax#}c_void{#endsyntax#} or any other {#link|@OpaqueType#}.</li>1888 {#syntax#}c_void{#endsyntax#} or any other {#link|opaque type|Opaque Types#}.</li>
1889 </ul>1889 </ul>
1890 </li>1890 </li>
1891 </ul>1891 </ul>
...@@ -5392,7 +5392,7 @@ fn eql_i32(a: i32, b: i32) bool {...@@ -5392,7 +5392,7 @@ fn eql_i32(a: i32, b: i32) bool {
5392 </p>5392 </p>
5393 <p>5393 <p>
5394 {#syntax#}void{#endsyntax#} is distinct from {#syntax#}c_void{#endsyntax#}, which is defined like this:5394 {#syntax#}void{#endsyntax#} is distinct from {#syntax#}c_void{#endsyntax#}, which is defined like this:
5395 {#syntax#}pub const c_void = @OpaqueType();{#endsyntax#}.5395 {#syntax#}pub const c_void = @Type(.Opaque);{#endsyntax#}.
5396 {#syntax#}void{#endsyntax#} has a known size of 0 bytes, and {#syntax#}c_void{#endsyntax#} has an unknown, but non-zero, size.5396 {#syntax#}void{#endsyntax#} has a known size of 0 bytes, and {#syntax#}c_void{#endsyntax#} has an unknown, but non-zero, size.
5397 </p>5397 </p>
5398 <p>5398 <p>
...@@ -7666,30 +7666,6 @@ mem.set(u8, dest, c);{#endsyntax#}</pre>...@@ -7666,30 +7666,6 @@ mem.set(u8, dest, c);{#endsyntax#}</pre>
7666 </p>7666 </p>
7667 {#header_close#}7667 {#header_close#}
76687668
7669 {#header_open|@OpaqueType#}
7670 <pre>{#syntax#}@OpaqueType() type{#endsyntax#}</pre>
7671 <p>
7672 Creates a new type with an unknown (but non-zero) size and alignment.
7673 </p>
7674 <p>
7675 This is typically used for type safety when interacting with C code that does not expose struct details.
7676 Example:
7677 </p>
7678 {#code_begin|test_err|expected type '*Derp', found '*Wat'#}
7679const Derp = @OpaqueType();
7680const Wat = @OpaqueType();
7681
7682extern fn bar(d: *Derp) void;
7683fn foo(w: *Wat) callconv(.C) void {
7684 bar(w);
7685}
7686
7687test "call foo" {
7688 foo(undefined);
7689}
7690 {#code_end#}
7691 {#header_close#}
7692
7693 {#header_open|@panic#}7669 {#header_open|@panic#}
7694 <pre>{#syntax#}@panic(message: []const u8) noreturn{#endsyntax#}</pre>7670 <pre>{#syntax#}@panic(message: []const u8) noreturn{#endsyntax#}</pre>
7695 <p>7671 <p>
...@@ -8274,21 +8250,21 @@ test "integer truncation" {...@@ -8274,21 +8250,21 @@ test "integer truncation" {
8274 <li>{#syntax#}comptime_float{#endsyntax#}</li>8250 <li>{#syntax#}comptime_float{#endsyntax#}</li>
8275 <li>{#syntax#}@TypeOf(undefined){#endsyntax#}</li>8251 <li>{#syntax#}@TypeOf(undefined){#endsyntax#}</li>
8276 <li>{#syntax#}@TypeOf(null){#endsyntax#}</li>8252 <li>{#syntax#}@TypeOf(null){#endsyntax#}</li>
8253 <li>{#link|Arrays#}</li>
8254 <li>{#link|Optionals#}</li>
8255 <li>{#link|Error Union Type#}</li>
8256 <li>{#link|Vectors#}</li>
8257 <li>{#link|Opaque Types#}</li>
8258 <li>AnyFrame</li>
8277 </ul>8259 </ul>
8278 <p>8260 <p>
8279 For these types it is a8261 For these types it is a
8280 <a href="https://github.com/ziglang/zig/issues/2907">TODO in the compiler to implement</a>:8262 <a href="https://github.com/ziglang/zig/issues/2907">TODO in the compiler to implement</a>:
8281 </p>8263 </p>
8282 <ul>8264 <ul>
8283 <li>Array</li>
8284 <li>Optional</li>
8285 <li>ErrorUnion</li>
8286 <li>ErrorSet</li>8265 <li>ErrorSet</li>
8287 <li>Enum</li>8266 <li>Enum</li>
8288 <li>Opaque</li>
8289 <li>FnFrame</li>8267 <li>FnFrame</li>
8290 <li>AnyFrame</li>
8291 <li>Vector</li>
8292 <li>EnumLiteral</li>8268 <li>EnumLiteral</li>
8293 </ul>8269 </ul>
8294 <p>8270 <p>
...@@ -8373,6 +8349,28 @@ fn foo(comptime T: type, ptr: *T) T {...@@ -8373,6 +8349,28 @@ fn foo(comptime T: type, ptr: *T) T {
8373 {#header_close#}8349 {#header_close#}
8374 {#header_close#}8350 {#header_close#}
83758351
8352 {#header_open|Opaque Types#}
8353 {#syntax#}@Type(.Opaque){#endsyntax#} creates a new type with an unknown (but non-zero) size and alignment.
8354 </p>
8355 <p>
8356 This is typically used for type safety when interacting with C code that does not expose struct details.
8357 Example:
8358 </p>
8359 {#code_begin|test_err|expected type '*Derp', found '*Wat'#}
8360const Derp = @Type(.Opaque);
8361const Wat = @Type(.Opaque);
8362
8363extern fn bar(d: *Derp) void;
8364fn foo(w: *Wat) callconv(.C) void {
8365 bar(w);
8366}
8367
8368test "call foo" {
8369 foo(undefined);
8370}
8371 {#code_end#}
8372 {#header_close#}
8373
8376 {#header_open|Build Mode#}8374 {#header_open|Build Mode#}
8377 <p>8375 <p>
8378 Zig has four build modes:8376 Zig has four build modes: