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
signature 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" {
18851885 <li>Supports slice syntax: {#syntax#}ptr[start..end]{#endsyntax#}</li>
18861886 <li>Supports pointer arithmetic: {#syntax#}ptr + x{#endsyntax#}, {#syntax#}ptr - x{#endsyntax#}</li>
18871887 <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>
18891889 </ul>
18901890 </li>
18911891 </ul>
......@@ -5392,7 +5392,7 @@ fn eql_i32(a: i32, b: i32) bool {
53925392 </p>
53935393 <p>
53945394 {#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#}.
53965396 {#syntax#}void{#endsyntax#} has a known size of 0 bytes, and {#syntax#}c_void{#endsyntax#} has an unknown, but non-zero, size.
53975397 </p>
53985398 <p>
......@@ -7666,30 +7666,6 @@ mem.set(u8, dest, c);{#endsyntax#}</pre>
76667666 </p>
76677667 {#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
76937669 {#header_open|@panic#}
76947670 <pre>{#syntax#}@panic(message: []const u8) noreturn{#endsyntax#}</pre>
76957671 <p>
......@@ -8274,21 +8250,21 @@ test "integer truncation" {
82748250 <li>{#syntax#}comptime_float{#endsyntax#}</li>
82758251 <li>{#syntax#}@TypeOf(undefined){#endsyntax#}</li>
82768252 <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>
82778259 </ul>
82788260 <p>
82798261 For these types it is a
82808262 <a href="https://github.com/ziglang/zig/issues/2907">TODO in the compiler to implement</a>:
82818263 </p>
82828264 <ul>
8283 <li>Array</li>
8284 <li>Optional</li>
8285 <li>ErrorUnion</li>
82868265 <li>ErrorSet</li>
82878266 <li>Enum</li>
8288 <li>Opaque</li>
82898267 <li>FnFrame</li>
8290 <li>AnyFrame</li>
8291 <li>Vector</li>
82928268 <li>EnumLiteral</li>
82938269 </ul>
82948270 <p>
......@@ -8373,6 +8349,28 @@ fn foo(comptime T: type, ptr: *T) T {
83738349 {#header_close#}
83748350 {#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
83768374 {#header_open|Build Mode#}
83778375 <p>
83788376 Zig has four build modes: