authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-14 10:35:03-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-14 10:35:03-04:00
log5e39328542094043bc7b34787ced45dbffe3abee
tree3440e35c30d8c6095282f98a337b0736a2b6e8a4
parent3d38feded93cb2ccecf5ecb538c8957a965a891e
signaturelock-open Commit is signed but in an unrecognized format.

docs: more syntax highlighting


2 files changed, 687 insertions(+), 660 deletions(-)

doc/docgen.zig+29-5
......@@ -300,6 +300,7 @@ const Node = union(enum) {
300300 SeeAlso: []const SeeAlsoItem,
301301 Code: Code,
302302 Link: Link,
303 Syntax: Token,
303304};
304305
305306const Toc = struct {
......@@ -530,6 +531,17 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
530531 },
531532 });
532533 tokenizer.code_node_count += 1;
534 } else if (mem.eql(u8, tag_name, "syntax")) {
535 _ = try eatToken(tokenizer, Token.Id.BracketClose);
536 const content_tok = try eatToken(tokenizer, Token.Id.Content);
537 _ = try eatToken(tokenizer, Token.Id.BracketOpen);
538 const end_syntax_tag = try eatToken(tokenizer, Token.Id.TagContent);
539 const end_tag_name = tokenizer.buffer[end_syntax_tag.start..end_syntax_tag.end];
540 if (!mem.eql(u8, end_tag_name, "endsyntax")) {
541 return parseError(tokenizer, end_syntax_tag, "invalid token inside syntax: {}", end_tag_name);
542 }
543 _ = try eatToken(tokenizer, Token.Id.BracketClose);
544 try nodes.append(Node{ .Syntax = content_tok });
533545 } else {
534546 return parseError(tokenizer, tag_token, "unrecognized tag name: {}", tag_name);
535547 }
......@@ -706,8 +718,10 @@ fn isType(name: []const u8) bool {
706718 return false;
707719}
708720
709fn tokenizeAndPrint(allocator: *mem.Allocator, out: var, src: []const u8) !void {
710 try out.write("<pre><code class=\"zig\">");
721fn tokenizeAndPrint(allocator: *mem.Allocator, docgen_tokenizer: *Tokenizer, out: var, source_token: Token) !void {
722 const raw_src = docgen_tokenizer.buffer[source_token.start..source_token.end];
723 const src = mem.trim(u8, raw_src, " \n");
724 try out.write("<code class=\"zig\">");
711725 var tokenizer = std.zig.Tokenizer.init(src);
712726 var index: usize = 0;
713727 var next_tok_is_fn = false;
......@@ -900,12 +914,17 @@ fn tokenizeAndPrint(allocator: *mem.Allocator, out: var, src: []const u8) !void
900914 std.zig.Token.Id.AngleBracketAngleBracketRightEqual,
901915 std.zig.Token.Id.Tilde,
902916 std.zig.Token.Id.BracketStarBracket,
903 std.zig.Token.Id.Invalid,
904917 => try writeEscaped(out, src[token.start..token.end]),
918
919 std.zig.Token.Id.Invalid => return parseError(
920 docgen_tokenizer,
921 source_token,
922 "syntax error",
923 ),
905924 }
906925 index = token.end;
907926 }
908 try out.write("</code></pre>");
927 try out.write("</code>");
909928}
910929
911930fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var, zig_exe: []const u8) !void {
......@@ -947,6 +966,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
947966 }
948967 try out.write("</ul>\n");
949968 },
969 Node.Syntax => |content_tok| {
970 try tokenizeAndPrint(allocator, tokenizer, out, content_tok);
971 },
950972 Node.Code => |code| {
951973 code_progress_index += 1;
952974 warn("docgen example code {}/{}...", code_progress_index, tokenizer.code_node_count);
......@@ -956,7 +978,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
956978 if (!code.is_inline) {
957979 try out.print("<p class=\"file\">{}.zig</p>", code.name);
958980 }
959 try tokenizeAndPrint(allocator, out, trimmed_raw_source);
981 try out.write("<pre>");
982 try tokenizeAndPrint(allocator, tokenizer, out, code.source_token);
983 try out.write("</pre>");
960984 const name_plus_ext = try std.fmt.allocPrint(allocator, "{}.zig", code.name);
961985 const tmp_source_file_name = try os.path.join(allocator, tmp_dir_name, name_plus_ext);
962986 try io.writeFile(tmp_source_file_name, trimmed_raw_source);
doc/langref.html.in+658-655
......@@ -161,8 +161,8 @@ pub fn main() void {
161161}
162162 {#code_end#}
163163 <p>
164 Note that we also left off the <code class="zig">!</code> from the return type.
165 In Zig, if your main function cannot fail, you must use the <code class="zig">void</code> return type.
164 Note that we also left off the {#syntax#}!{#endsyntax#} from the return type.
165 In Zig, if your main function cannot fail, you must use the {#syntax#}void{#endsyntax#} return type.
166166 </p>
167167 {#see_also|Values|@import|Errors|Root Source File#}
168168 {#header_close#}
......@@ -181,14 +181,14 @@ test "comments" {
181181}
182182 {#code_end#}
183183 <p>
184 There are no multiline comments in Zig (e.g. like <code>/* */</code>
184 There are no multiline comments in Zig (e.g. like <code class="c">/* */</code>
185185 comments in C). This helps allow Zig to have the property that each line
186186 of code can be tokenized out of context.
187187 </p>
188188 {#header_open|Doc comments#}
189189 <p>
190190 A doc comment is one that begins with exactly three slashes (i.e.
191 <code class="zig">///</code> but not <code class="zig">////</code>);
191 {#syntax#}///{#endsyntax#} but not {#syntax#}////{#endsyntax#});
192192 multiple doc comments in a row are merged together to form a multiline
193193 doc comment. The doc comment documents whatever immediately follows it.
194194 </p>
......@@ -280,169 +280,169 @@ pub fn main() void {
280280 </th>
281281 </tr>
282282 <tr>
283 <td><code>i8</code></td>
284 <td><code>int8_t</code></td>
283 <td>{#syntax#}i8{#endsyntax#}</td>
284 <td><code class="c">int8_t</code></td>
285285 <td>signed 8-bit integer</td>
286286 </tr>
287287 <tr>
288 <td><code>u8</code></td>
289 <td><code>uint8_t</code></td>
288 <td>{#syntax#}u8{#endsyntax#}</td>
289 <td><code class="c">uint8_t</code></td>
290290 <td>unsigned 8-bit integer</td>
291291 </tr>
292292 <tr>
293 <td><code>i16</code></td>
294 <td><code>int16_t</code></td>
293 <td>{#syntax#}i16{#endsyntax#}</td>
294 <td><code class="c">int16_t</code></td>
295295 <td>signed 16-bit integer</td>
296296 </tr>
297297 <tr>
298 <td><code>u16</code></td>
299 <td><code>uint16_t</code></td>
298 <td>{#syntax#}u16{#endsyntax#}</td>
299 <td><code class="c">uint16_t</code></td>
300300 <td>unsigned 16-bit integer</td>
301301 </tr>
302302 <tr>
303 <td><code>i32</code></td>
304 <td><code>int32_t</code></td>
303 <td>{#syntax#}i32{#endsyntax#}</td>
304 <td><code class="c">int32_t</code></td>
305305 <td>signed 32-bit integer</td>
306306 </tr>
307307 <tr>
308 <td><code>u32</code></td>
309 <td><code>uint32_t</code></td>
308 <td>{#syntax#}u32{#endsyntax#}</td>
309 <td><code class="c">uint32_t</code></td>
310310 <td>unsigned 32-bit integer</td>
311311 </tr>
312312 <tr>
313 <td><code>i64</code></td>
314 <td><code>int64_t</code></td>
313 <td>{#syntax#}i64{#endsyntax#}</td>
314 <td><code class="c">int64_t</code></td>
315315 <td>signed 64-bit integer</td>
316316 </tr>
317317 <tr>
318 <td><code>u64</code></td>
319 <td><code>uint64_t</code></td>
318 <td>{#syntax#}u64{#endsyntax#}</td>
319 <td><code class="c">uint64_t</code></td>
320320 <td>unsigned 64-bit integer</td>
321321 </tr>
322322 <tr>
323 <td><code>i128</code></td>
324 <td><code>__int128</code></td>
323 <td>{#syntax#}i128{#endsyntax#}</td>
324 <td><code class="c">__int128</code></td>
325325 <td>signed 128-bit integer</td>
326326 </tr>
327327 <tr>
328 <td><code>u128</code></td>
329 <td><code>unsigned __int128</code></td>
328 <td>{#syntax#}u128{#endsyntax#}</td>
329 <td><code class="c">unsigned __int128</code></td>
330330 <td>unsigned 128-bit integer</td>
331331 </tr>
332332 <tr>
333 <td><code>isize</code></td>
334 <td><code>intptr_t</code></td>
333 <td>{#syntax#}isize{#endsyntax#}</td>
334 <td><code class="c">intptr_t</code></td>
335335 <td>signed pointer sized integer</td>
336336 </tr>
337337 <tr>
338 <td><code>usize</code></td>
339 <td><code>uintptr_t</code></td>
338 <td>{#syntax#}usize{#endsyntax#}</td>
339 <td><code class="c">uintptr_t</code></td>
340340 <td>unsigned pointer sized integer</td>
341341 </tr>
342342
343343 <tr>
344 <td><code>c_short</code></td>
345 <td><code>short</code></td>
344 <td>{#syntax#}c_short{#endsyntax#}</td>
345 <td><code class="c">short</code></td>
346346 <td>for ABI compatibility with C</td>
347347 </tr>
348348 <tr>
349 <td><code>c_ushort</code></td>
350 <td><code>unsigned short</code></td>
349 <td>{#syntax#}c_ushort{#endsyntax#}</td>
350 <td><code class="c">unsigned short</code></td>
351351 <td>for ABI compatibility with C</td>
352352 </tr>
353353 <tr>
354 <td><code>c_int</code></td>
355 <td><code>int</code></td>
354 <td>{#syntax#}c_int{#endsyntax#}</td>
355 <td><code class="c">int</code></td>
356356 <td>for ABI compatibility with C</td>
357357 </tr>
358358 <tr>
359 <td><code>c_uint</code></td>
360 <td><code>unsigned int</code></td>
359 <td>{#syntax#}c_uint{#endsyntax#}</td>
360 <td><code class="c">unsigned int</code></td>
361361 <td>for ABI compatibility with C</td>
362362 </tr>
363363 <tr>
364 <td><code>c_long</code></td>
365 <td><code>long</code></td>
364 <td>{#syntax#}c_long{#endsyntax#}</td>
365 <td><code class="c">long</code></td>
366366 <td>for ABI compatibility with C</td>
367367 </tr>
368368 <tr>
369 <td><code>c_ulong</code></td>
370 <td><code>unsigned long</code></td>
369 <td>{#syntax#}c_ulong{#endsyntax#}</td>
370 <td><code class="c">unsigned long</code></td>
371371 <td>for ABI compatibility with C</td>
372372 </tr>
373373 <tr>
374 <td><code>c_longlong</code></td>
375 <td><code>long long</code></td>
374 <td>{#syntax#}c_longlong{#endsyntax#}</td>
375 <td><code class="c">long long</code></td>
376376 <td>for ABI compatibility with C</td>
377377 </tr>
378378 <tr>
379 <td><code>c_ulonglong</code></td>
380 <td><code>unsigned long long</code></td>
379 <td>{#syntax#}c_ulonglong{#endsyntax#}</td>
380 <td><code class="c">unsigned long long</code></td>
381381 <td>for ABI compatibility with C</td>
382382 </tr>
383383 <tr>
384 <td><code>c_longdouble</code></td>
385 <td><code>long double</code></td>
384 <td>{#syntax#}c_longdouble{#endsyntax#}</td>
385 <td><code class="c">long double</code></td>
386386 <td>for ABI compatibility with C</td>
387387 </tr>
388388 <tr>
389 <td><code>c_void</code></td>
390 <td><code>void</code></td>
389 <td>{#syntax#}c_void{#endsyntax#}</td>
390 <td><code class="c">void</code></td>
391391 <td>for ABI compatibility with C</td>
392392 </tr>
393393
394394 <tr>
395 <td><code>f16</code></td>
396 <td><code>float</code></td>
395 <td>{#syntax#}f16{#endsyntax#}</td>
396 <td><code class="c">float</code></td>
397397 <td>16-bit floating point (10-bit mantissa) IEEE-754-2008 binary16</td>
398398 </tr>
399399 <tr>
400 <td><code>f32</code></td>
401 <td><code>float</code></td>
400 <td>{#syntax#}f32{#endsyntax#}</td>
401 <td><code class="c">float</code></td>
402402 <td>32-bit floating point (23-bit mantissa) IEEE-754-2008 binary32</td>
403403 </tr>
404404 <tr>
405 <td><code>f64</code></td>
406 <td><code>double</code></td>
405 <td>{#syntax#}f64{#endsyntax#}</td>
406 <td><code class="c">double</code></td>
407407 <td>64-bit floating point (52-bit mantissa) IEEE-754-2008 binary64</td>
408408 </tr>
409409 <tr>
410 <td><code>f128</code></td>
410 <td>{#syntax#}f128{#endsyntax#}</td>
411411 <td>(none)</td>
412412 <td>128-bit floating point (112-bit mantissa) IEEE-754-2008 binary128</td>
413413 </tr>
414414 <tr>
415 <td><code>bool</code></td>
416 <td><code>bool</code></td>
417 <td><code>true</code> or <code>false</code></td>
415 <td>{#syntax#}bool{#endsyntax#}</td>
416 <td><code class="c">bool</code></td>
417 <td>{#syntax#}true{#endsyntax#} or {#syntax#}false{#endsyntax#}</td>
418418 </tr>
419419 <tr>
420 <td><code>void</code></td>
420 <td>{#syntax#}void{#endsyntax#}</td>
421421 <td>(none)</td>
422422 <td>0 bit type</td>
423423 </tr>
424424 <tr>
425 <td><code>noreturn</code></td>
425 <td>{#syntax#}noreturn{#endsyntax#}</td>
426426 <td>(none)</td>
427 <td>the type of <code>break</code>, <code>continue</code>, <code>return</code>, <code>unreachable</code>, and <code>while (true) {}</code></td>
427 <td>the type of {#syntax#}break{#endsyntax#}, {#syntax#}continue{#endsyntax#}, {#syntax#}return{#endsyntax#}, {#syntax#}unreachable{#endsyntax#}, and {#syntax#}while (true) {}{#endsyntax#}</td>
428428 </tr>
429429 <tr>
430 <td><code>type</code></td>
430 <td>{#syntax#}type{#endsyntax#}</td>
431431 <td>(none)</td>
432432 <td>the type of types</td>
433433 </tr>
434434 <tr>
435 <td><code>error</code></td>
435 <td>{#syntax#}error{#endsyntax#}</td>
436436 <td>(none)</td>
437437 <td>an error code</td>
438438 </tr>
439439 <tr>
440 <td><code>comptime_int</code></td>
440 <td>{#syntax#}comptime_int{#endsyntax#}</td>
441441 <td>(none)</td>
442442 <td>Only allowed for {#link|comptime#}-known values. The type of integer literals.</td>
443443 </tr>
444444 <tr>
445 <td><code>comptime_float</code></td>
445 <td>{#syntax#}comptime_float{#endsyntax#}</td>
446446 <td>(none)</td>
447447 <td>Only allowed for {#link|comptime#}-known values. The type of float literals.</td>
448448 </tr>
......@@ -451,7 +451,7 @@ pub fn main() void {
451451 <p>
452452 In addition to the integer types above, arbitrary bit-width integers can be referenced by using
453453 an identifier of <code>i</code> or </code>u</code> followed by digits. For example, the identifier
454 <code>i7</code> refers to a signed 7-bit integer.
454 {#syntax#}i7{#endsyntax#} refers to a signed 7-bit integer.
455455 </p>
456456 {#see_also|Integers|Floats|void|Errors#}
457457 {#header_close#}
......@@ -467,15 +467,15 @@ pub fn main() void {
467467 </th>
468468 </tr>
469469 <tr>
470 <td><code>true</code> and <code>false</code></td>
471 <td><code>bool</code> values</td>
470 <td>{#syntax#}true{#endsyntax#} and {#syntax#}false{#endsyntax#}</td>
471 <td>{#syntax#}bool{#endsyntax#} values</td>
472472 </tr>
473473 <tr>
474 <td><code>null</code></td>
475 <td>used to set an optional type to <code>null</code></td>
474 <td>{#syntax#}null{#endsyntax#}</td>
475 <td>used to set an optional type to {#syntax#}null{#endsyntax#}</td>
476476 </tr>
477477 <tr>
478 <td><code>undefined</code></td>
478 <td>{#syntax#}undefined{#endsyntax#}</td>
479479 <td>used to leave a value unspecified</td>
480480 </tr>
481481 </table>
......@@ -515,52 +515,52 @@ test "string literals" {
515515 </th>
516516 </tr>
517517 <tr>
518 <td><code>\n</code></td>
518 <td><code>\n</code></td>
519519 <td>Newline</td>
520520 </tr>
521521 <tr>
522 <td><code>\r</code></td>
522 <td><code>\r</code></td>
523523 <td>Carriage Return</td>
524524 </tr>
525525 <tr>
526 <td><code>\t</code></td>
526 <td><code>\t</code></td>
527527 <td>Tab</td>
528528 </tr>
529529 <tr>
530 <td><code>\\</code></td>
530 <td><code>\\</code></td>
531531 <td>Backslash</td>
532532 </tr>
533533 <tr>
534 <td><code>\'</code></td>
534 <td><code>\'</code></td>
535535 <td>Single Quote</td>
536536 </tr>
537537 <tr>
538 <td><code>\"</code></td>
538 <td><code>\"</code></td>
539539 <td>Double Quote</td>
540540 </tr>
541541 <tr>
542 <td><code>\xNN</code></td>
542 <td><code>\xNN</code></td>
543543 <td>hexadecimal 8-bit character code (2 digits)</td>
544544 </tr>
545545 <tr>
546 <td><code>\uNNNN</code></td>
546 <td><code>\uNNNN</code></td>
547547 <td>hexadecimal 16-bit Unicode character code UTF-8 encoded (4 digits)</td>
548548 </tr>
549549 <tr>
550 <td><code>\UNNNNNN</code></td>
550 <td><code>\UNNNNNN</code></td>
551551 <td>hexadecimal 24-bit Unicode character code UTF-8 encoded (6 digits)</td>
552552 </tr>
553553 </table>
554554 </div>
555 <p>Note that the maximum valid Unicode point is <code>0x10ffff</code>.</p>
555 <p>Note that the maximum valid Unicode point is {#syntax#}0x10ffff{#endsyntax#}.</p>
556556 {#header_close#}
557557 {#header_open|Multiline String Literals#}
558558 <p>
559559 Multiline string literals have no escapes and can span across multiple lines.
560 To start a multiline string literal, use the <code>\\</code> token. Just like a comment,
560 To start a multiline string literal, use the {#syntax#}\\{#endsyntax#} token. Just like a comment,
561561 the string literal goes until the end of the line. The end of the line is
562562 not included in the string literal.
563 However, if the next line begins with <code>\\</code> then a newline is appended and
563 However, if the next line begins with {#syntax#}\\{#endsyntax#} then a newline is appended and
564564 the string literal continues.
565565 </p>
566566 {#code_begin|syntax#}
......@@ -574,7 +574,7 @@ const hello_world_in_c =
574574;
575575 {#code_end#}
576576 <p>
577 For a multiline C string literal, prepend <code>c</code> to each <code>\\</code>:
577 For a multiline C string literal, prepend <code>c</code> to each {#syntax#}\\{#endsyntax#}:
578578 </p>
579579 {#code_begin|syntax#}
580580const c_string_literal =
......@@ -587,14 +587,14 @@ const c_string_literal =
587587;
588588 {#code_end#}
589589 <p>
590 In this example the variable <code>c_string_literal</code> has type <code>[*]const char</code> and
590 In this example the variable {#syntax#}c_string_literal{#endsyntax#} has type {#syntax#}[*]const char{#endsyntax#} and
591591 has a terminating null byte.
592592 </p>
593593 {#see_also|@embedFile#}
594594 {#header_close#}
595595 {#header_close#}
596596 {#header_open|Assignment#}
597 <p>Use the <code>const</code> keyword to assign a value to an identifier:</p>
597 <p>Use the {#syntax#}const{#endsyntax#} keyword to assign a value to an identifier:</p>
598598 {#code_begin|test_err|cannot assign to constant#}
599599const x = 1234;
600600
......@@ -610,8 +610,8 @@ test "assignment" {
610610 foo();
611611}
612612 {#code_end#}
613 <p><code>const</code> applies to all of the bytes that the identifier immediately addresses. {#link|Pointers#} have their own const-ness.</p>
614 <p>If you need a variable that you can modify, use the <code>var</code> keyword:</p>
613 <p>{#syntax#}const{#endsyntax#} applies to all of the bytes that the identifier immediately addresses. {#link|Pointers#} have their own const-ness.</p>
614 <p>If you need a variable that you can modify, use the {#syntax#}var{#endsyntax#} keyword:</p>
615615 {#code_begin|test#}
616616const assert = @import("std").debug.assert;
617617
......@@ -632,7 +632,7 @@ test "initialization" {
632632}
633633 {#code_end#}
634634 {#header_open|undefined#}
635 <p>Use <code>undefined</code> to leave variables uninitialized:</p>
635 <p>Use {#syntax#}undefined{#endsyntax#} to leave variables uninitialized:</p>
636636 {#code_begin|test#}
637637const assert = @import("std").debug.assert;
638638
......@@ -643,14 +643,14 @@ test "init with undefined" {
643643}
644644 {#code_end#}
645645 <p>
646 <code>undefined</code> can be {#link|implicitly cast|Implicit Casts#} to any type.
647 Once this happens, it is no longer possible to detect that the value is <code>undefined</code>.
648 <code>undefined</code> means the value could be anything, even something that is nonsense
649 according to the type. Translated into English, <code>undefined</code> means "Not a meaningful
646 {#syntax#}undefined{#endsyntax#} can be {#link|implicitly cast|Implicit Casts#} to any type.
647 Once this happens, it is no longer possible to detect that the value is {#syntax#}undefined{#endsyntax#}.
648 {#syntax#}undefined{#endsyntax#} means the value could be anything, even something that is nonsense
649 according to the type. Translated into English, {#syntax#}undefined{#endsyntax#} means "Not a meaningful
650650 value. Using this value would be a bug. The value will be unused, or overwritten before being used."
651651 </p>
652652 <p>
653 In {#link|Debug#} mode, Zig writes <code>0xaa</code> bytes to undefined memory. This is to catch
653 In {#link|Debug#} mode, Zig writes {#syntax#}0xaa{#endsyntax#} bytes to undefined memory. This is to catch
654654 bugs early, and to help detect use of undefined memory in a debugger.
655655 </p>
656656 {#header_close#}
......@@ -681,14 +681,14 @@ fn divide(a: i32, b: i32) i32 {
681681}
682682 {#code_end#}
683683 <p>
684 In this function, values <code>a</code> and <code>b</code> are known only at runtime,
684 In this function, values {#syntax#}a{#endsyntax#} and {#syntax#}b{#endsyntax#} are known only at runtime,
685685 and thus this division operation is vulnerable to both integer overflow and
686686 division by zero.
687687 </p>
688688 <p>
689 Operators such as <code>+</code> and <code>-</code> cause undefined behavior on
690 integer overflow. Also available are operations such as <code>+%</code> and
691 <code>-%</code> which are defined to have wrapping arithmetic on all targets.
689 Operators such as {#syntax#}+{#endsyntax#} and {#syntax#}-{#endsyntax#} cause undefined behavior on
690 integer overflow. Also available are operations such as {#syntax#}+%{#endsyntax#} and
691 {#syntax#}-%{#endsyntax#} which are defined to have wrapping arithmetic on all targets.
692692 </p>
693693 {#see_also|Integer Overflow|Division by Zero|Wrapping Operations#}
694694 {#header_close#}
......@@ -696,15 +696,15 @@ fn divide(a: i32, b: i32) i32 {
696696 {#header_open|Floats#}
697697 <p>Zig has the following floating point types:</p>
698698 <ul>
699 <li><code>f16</code> - IEEE-754-2008 binary16</li>
700 <li><code>f32</code> - IEEE-754-2008 binary32</li>
701 <li><code>f64</code> - IEEE-754-2008 binary64</li>
702 <li><code>f128</code> - IEEE-754-2008 binary128</li>
703 <li><code>c_longdouble</code> - matches <code>long double</code> for the target C ABI</li>
699 <li>{#syntax#}f16{#endsyntax#} - IEEE-754-2008 binary16</li>
700 <li>{#syntax#}f32{#endsyntax#} - IEEE-754-2008 binary32</li>
701 <li>{#syntax#}f64{#endsyntax#} - IEEE-754-2008 binary64</li>
702 <li>{#syntax#}f128{#endsyntax#} - IEEE-754-2008 binary128</li>
703 <li>{#syntax#}c_longdouble{#endsyntax#} - matches <code class="c">long double</code> for the target C ABI</li>
704704 </ul>
705705 {#header_open|Float Literals#}
706706 <p>
707 Float literals have type <code>comptime_float</code> which is guaranteed to hold at least all possible values
707 Float literals have type {#syntax#}comptime_float{#endsyntax#} which is guaranteed to hold at least all possible values
708708 that the largest other floating point type can hold. Float literals {#link|implicitly cast|Implicit Casts#} to any other type.
709709 </p>
710710 {#code_begin|syntax#}
......@@ -718,8 +718,8 @@ const yet_another_hex_float = 0x103.70P-5;
718718 {#code_end#}
719719 {#header_close#}
720720 {#header_open|Floating Point Operations#}
721 <p>By default floating point operations use <code>Strict</code> mode,
722 but you can switch to <code>Optimized</code> mode on a per-block basis:</p>
721 <p>By default floating point operations use {#syntax#}Strict{#endsyntax#} mode,
722 but you can switch to {#syntax#}Optimized{#endsyntax#} mode on a per-block basis:</p>
723723 {#code_begin|obj|foo#}
724724 {#code_release_fast#}
725725const builtin = @import("builtin");
......@@ -772,8 +772,8 @@ pub fn main() void {
772772 </th>
773773 </tr>
774774 <tr>
775 <td><pre><code class="zig">a + b
776a += b</code></pre></td>
775 <td><pre>{#syntax#}a + b
776a += b{#endsyntax#}</pre></td>
777777 <td>
778778 <ul>
779779 <li>{#link|Integers#}</li>
......@@ -788,12 +788,12 @@ a += b</code></pre></td>
788788 </ul>
789789 </td>
790790 <td>
791 <pre><code class="zig">2 + 5 == 7</code></pre>
791 <pre>{#syntax#}2 + 5 == 7{#endsyntax#}</pre>
792792 </td>
793793 </tr>
794794 <tr>
795 <td><pre><code class="zig">a +% b
796a +%= b</code></pre></td>
795 <td><pre>{#syntax#}a +% b
796a +%= b{#endsyntax#}</pre></td>
797797 <td>
798798 <ul>
799799 <li>{#link|Integers#}</li>
......@@ -807,12 +807,12 @@ a +%= b</code></pre></td>
807807 </ul>
808808 </td>
809809 <td>
810 <pre><code class="zig">u32(@maxValue(u32)) +% 1 == 0</code></pre>
810 <pre>{#syntax#}u32(@maxValue(u32)) +% 1 == 0{#endsyntax#}</pre>
811811 </td>
812812 </tr>
813813 <tr>
814 <td><pre><code class="zig">a - b
815a -= b</code></pre></td>
814 <td><pre>{#syntax#}a - b
815a -= b{#endsyntax#}</pre></td>
816816 <td>
817817 <ul>
818818 <li>{#link|Integers#}</li>
......@@ -827,12 +827,12 @@ a -= b</code></pre></td>
827827 </ul>
828828 </td>
829829 <td>
830 <pre><code class="zig">2 - 5 == -3</code></pre>
830 <pre>{#syntax#}2 - 5 == -3{#endsyntax#}</pre>
831831 </td>
832832 </tr>
833833 <tr>
834 <td><pre><code class="zig">a -% b
835a -%= b</code></pre></td>
834 <td><pre>{#syntax#}a -% b
835a -%= b{#endsyntax#}</pre></td>
836836 <td>
837837 <ul>
838838 <li>{#link|Integers#}</li>
......@@ -846,11 +846,11 @@ a -%= b</code></pre></td>
846846 </ul>
847847 </td>
848848 <td>
849 <pre><code class="zig">u32(0) -% 1 == @maxValue(u32)</code></pre>
849 <pre>{#syntax#}u32(0) -% 1 == @maxValue(u32){#endsyntax#}</pre>
850850 </td>
851851 </tr>
852852 <tr>
853 <td><pre><code class="zig">-a<code></pre></td>
853 <td><pre>{#syntax#}-a{#endsyntax#}</pre></td>
854854 <td>
855855 <ul>
856856 <li>{#link|Integers#}</li>
......@@ -864,11 +864,11 @@ a -%= b</code></pre></td>
864864 </ul>
865865 </td>
866866 <td>
867 <pre><code class="zig">-1 == 0 - 1</code></pre>
867 <pre>{#syntax#}-1 == 0 - 1{#endsyntax#}</pre>
868868 </td>
869869 </tr>
870870 <tr>
871 <td><pre><code class="zig">-%a<code></pre></td>
871 <td><pre>{#syntax#}-%a{#endsyntax#}</pre></td>
872872 <td>
873873 <ul>
874874 <li>{#link|Integers#}</li>
......@@ -881,12 +881,12 @@ a -%= b</code></pre></td>
881881 </ul>
882882 </td>
883883 <td>
884 <pre><code class="zig">-%i32(@minValue(i32)) == @minValue(i32)</code></pre>
884 <pre>{#syntax#}-%i32(@minValue(i32)) == @minValue(i32){#endsyntax#}</pre>
885885 </td>
886886 </tr>
887887 <tr>
888 <td><pre><code class="zig">a * b
889a *= b</code></pre></td>
888 <td><pre>{#syntax#}a * b
889a *= b{#endsyntax#}</pre></td>
890890 <td>
891891 <ul>
892892 <li>{#link|Integers#}</li>
......@@ -901,12 +901,12 @@ a *= b</code></pre></td>
901901 </ul>
902902 </td>
903903 <td>
904 <pre><code class="zig">2 * 5 == 10</code></pre>
904 <pre>{#syntax#}2 * 5 == 10{#endsyntax#}</pre>
905905 </td>
906906 </tr>
907907 <tr>
908 <td><pre><code class="zig">a *% b
909a *%= b</code></pre></td>
908 <td><pre>{#syntax#}a *% b
909a *%= b{#endsyntax#}</pre></td>
910910 <td>
911911 <ul>
912912 <li>{#link|Integers#}</li>
......@@ -920,12 +920,12 @@ a *%= b</code></pre></td>
920920 </ul>
921921 </td>
922922 <td>
923 <pre><code class="zig">u8(200) *% 2 == 144</code></pre>
923 <pre>{#syntax#}u8(200) *% 2 == 144{#endsyntax#}</pre>
924924 </td>
925925 </tr>
926926 <tr>
927 <td><pre><code class="zig">a / b
928a /= b</code></pre></td>
927 <td><pre>{#syntax#}a / b
928a /= b{#endsyntax#}</pre></td>
929929 <td>
930930 <ul>
931931 <li>{#link|Integers#}</li>
......@@ -940,18 +940,18 @@ a /= b</code></pre></td>
940940 <li>For non-compile-time-known signed integers, must use
941941 {#link|@divTrunc#},
942942 {#link|@divFloor#}, or
943 {#link|@divExact#} instead of <code>/</code>.
943 {#link|@divExact#} instead of {#syntax#}/{#endsyntax#}.
944944 </li>
945945 <li>Invokes {#link|Peer Type Resolution#} for the operands.</li>
946946 </ul>
947947 </td>
948948 <td>
949 <pre><code class="zig">10 / 5 == 2</code></pre>
949 <pre>{#syntax#}10 / 5 == 2{#endsyntax#}</pre>
950950 </td>
951951 </tr>
952952 <tr>
953 <td><pre><code class="zig">a % b
954a %= b</code></pre></td>
953 <td><pre>{#syntax#}a % b
954a %= b{#endsyntax#}</pre></td>
955955 <td>
956956 <ul>
957957 <li>{#link|Integers#}</li>
......@@ -964,18 +964,18 @@ a %= b</code></pre></td>
964964 <li>Can cause {#link|Division by Zero#} for floats in {#link|FloatMode.Optimized Mode|Floating Point Operations#}.</li>
965965 <li>For non-compile-time-known signed integers, must use
966966 {#link|@rem#} or
967 {#link|@mod#} instead of <code>%</code>.
967 {#link|@mod#} instead of {#syntax#}%{#endsyntax#}.
968968 </li>
969969 <li>Invokes {#link|Peer Type Resolution#} for the operands.</li>
970970 </ul>
971971 </td>
972972 <td>
973 <pre><code class="zig">10 % 3 == 1</code></pre>
973 <pre>{#syntax#}10 % 3 == 1{#endsyntax#}</pre>
974974 </td>
975975 </tr>
976976 <tr>
977 <td><pre><code class="zig">a &lt;&lt; b
978a &lt;&lt;= b</code></pre></td>
977 <td><pre>{#syntax#}a << b
978a <<= b{#endsyntax#}</pre></td>
979979 <td>
980980 <ul>
981981 <li>{#link|Integers#}</li>
......@@ -983,18 +983,18 @@ a &lt;&lt;= b</code></pre></td>
983983 </td>
984984 <td>Bit Shift Left.
985985 <ul>
986 <li><code>b</code> must be {#link|comptime-known|comptime#} or have a type with log2 number of bits as <code>a</code>.</li>
986 <li>{#syntax#}b{#endsyntax#} must be {#link|comptime-known|comptime#} or have a type with log2 number of bits as {#syntax#}a{#endsyntax#}.</li>
987987 <li>See also {#link|@shlExact#}.</li>
988988 <li>See also {#link|@shlWithOverflow#}.</li>
989989 </ul>
990990 </td>
991991 <td>
992 <pre><code class="zig">1 &lt;&lt; 8 == 256</code></pre>
992 <pre>{#syntax#}1 << 8 == 256{#endsyntax#}</pre>
993993 </td>
994994 </tr>
995995 <tr>
996 <td><pre><code class="zig">a &gt;&gt; b
997a &gt;&gt;= b</code></pre></td>
996 <td><pre>{#syntax#}a >> b
997a >>= b{#endsyntax#}</pre></td>
998998 <td>
999999 <ul>
10001000 <li>{#link|Integers#}</li>
......@@ -1002,17 +1002,17 @@ a &gt;&gt;= b</code></pre></td>
10021002 </td>
10031003 <td>Bit Shift Right.
10041004 <ul>
1005 <li><code>b</code> must be {#link|comptime-known|comptime#} or have a type with log2 number of bits as <code>a</code>.</li>
1005 <li>{#syntax#}b{#endsyntax#} must be {#link|comptime-known|comptime#} or have a type with log2 number of bits as {#syntax#}a{#endsyntax#}.</li>
10061006 <li>See also {#link|@shrExact#}.</li>
10071007 </ul>
10081008 </td>
10091009 <td>
1010 <pre><code class="zig">10 &gt;&gt; 1 == 5</code></pre>
1010 <pre>{#syntax#}10 >> 1 == 5{#endsyntax#}</pre>
10111011 </td>
10121012 </tr>
10131013 <tr>
1014 <td><pre><code class="zig">a &amp; b
1015a &amp;= b</code></pre></td>
1014 <td><pre>{#syntax#}a & b
1015a &= b{#endsyntax#}</pre></td>
10161016 <td>
10171017 <ul>
10181018 <li>{#link|Integers#}</li>
......@@ -1024,12 +1024,12 @@ a &amp;= b</code></pre></td>
10241024 </ul>
10251025 </td>
10261026 <td>
1027 <pre><code class="zig">0b011 &amp; 0b101 == 0b001</code></pre>
1027 <pre>{#syntax#}0b011 &amp; 0b101 == 0b001{#endsyntax#}</pre>
10281028 </td>
10291029 </tr>
10301030 <tr>
1031 <td><pre><code class="zig">a | b
1032a |= b</code></pre></td>
1031 <td><pre>{#syntax#}a | b
1032a |= b{#endsyntax#}</pre></td>
10331033 <td>
10341034 <ul>
10351035 <li>{#link|Integers#}</li>
......@@ -1041,12 +1041,12 @@ a |= b</code></pre></td>
10411041 </ul>
10421042 </td>
10431043 <td>
1044 <pre><code class="zig">0b010 | 0b100 == 0b110</code></pre>
1044 <pre>{#syntax#}0b010 | 0b100 == 0b110{#endsyntax#}</pre>
10451045 </td>
10461046 </tr>
10471047 <tr>
1048 <td><pre><code class="zig">a ^ b
1049a ^= b</code></pre></td>
1048 <td><pre>{#syntax#}a ^ b
1049a ^= b{#endsyntax#}</pre></td>
10501050 <td>
10511051 <ul>
10521052 <li>{#link|Integers#}</li>
......@@ -1058,11 +1058,11 @@ a ^= b</code></pre></td>
10581058 </ul>
10591059 </td>
10601060 <td>
1061 <pre><code class="zig">0b011 ^ 0b101 == 0b110</code></pre>
1061 <pre>{#syntax#}0b011 ^ 0b101 == 0b110{#endsyntax#}</pre>
10621062 </td>
10631063 </tr>
10641064 <tr>
1065 <td><pre><code class="zig">~a<code></pre></td>
1065 <td><pre>{#syntax#}~a{#endsyntax#}</pre></td>
10661066 <td>
10671067 <ul>
10681068 <li>{#link|Integers#}</li>
......@@ -1072,29 +1072,29 @@ a ^= b</code></pre></td>
10721072 Bitwise NOT.
10731073 </td>
10741074 <td>
1075 <pre><code class="zig">~u8(0b0101111) == 0b1010000</code></pre>
1075 <pre>{#syntax#}~u8(0b0101111) == 0b1010000{#endsyntax#}</pre>
10761076 </td>
10771077 </tr>
10781078 <tr>
1079 <td><pre><code class="zig">a orelse b</code></pre></td>
1079 <td><pre>{#syntax#}a orelse b{#endsyntax#}</pre></td>
10801080 <td>
10811081 <ul>
10821082 <li>{#link|Optionals#}</li>
10831083 </ul>
10841084 </td>
1085 <td>If <code>a</code> is <code>null</code>,
1086 returns <code>b</code> ("default value"),
1087 otherwise returns the unwrapped value of <code>a</code>.
1088 Note that <code>b</code> may be a value of type {#link|noreturn#}.
1085 <td>If {#syntax#}a{#endsyntax#} is {#syntax#}null{#endsyntax#},
1086 returns {#syntax#}b{#endsyntax#} ("default value"),
1087 otherwise returns the unwrapped value of {#syntax#}a{#endsyntax#}.
1088 Note that {#syntax#}b{#endsyntax#} may be a value of type {#link|noreturn#}.
10891089 </td>
10901090 <td>
1091 <pre><code class="zig">const value: ?u32 = null;
1091 <pre>{#syntax#}const value: ?u32 = null;
10921092const unwrapped = value orelse 1234;
1093unwrapped == 1234</code></pre>
1093unwrapped == 1234{#endsyntax#}</pre>
10941094 </td>
10951095 </tr>
10961096 <tr>
1097 <td><pre><code class="zig">a.?</code></pre></td>
1097 <td><pre>{#syntax#}a.?{#endsyntax#}</pre></td>
10981098 <td>
10991099 <ul>
11001100 <li>{#link|Optionals#}</li>
......@@ -1102,65 +1102,65 @@ unwrapped == 1234</code></pre>
11021102 </td>
11031103 <td>
11041104 Equivalent to:
1105 <pre><code class="zig">a orelse unreachable</code></pre>
1105 <pre>{#syntax#}a orelse unreachable{#endsyntax#}</pre>
11061106 </td>
11071107 <td>
1108 <pre><code class="zig">const value: ?u32 = 5678;
1109value.? == 5678</code></pre>
1108 <pre>{#syntax#}const value: ?u32 = 5678;
1109value.? == 5678{#endsyntax#}</pre>
11101110 </td>
11111111 </tr>
11121112 <tr>
1113 <td><pre><code class="zig">a catch b
1114a catch |err| b</code></pre></td>
1113 <td><pre>{#syntax#}a catch b
1114a catch |err| b{#endsyntax#}</pre></td>
11151115 <td>
11161116 <ul>
11171117 <li>{#link|Error Unions|Errors#}</li>
11181118 </ul>
11191119 </td>
1120 <td>If <code>a</code> is an <code>error</code>,
1121 returns <code>b</code> ("default value"),
1122 otherwise returns the unwrapped value of <code>a</code>.
1123 Note that <code>b</code> may be a value of type {#link|noreturn#}.
1124 <code>err</code> is the <code>error</code> and is in scope of the expression <code>b</code>.
1120 <td>If {#syntax#}a{#endsyntax#} is an {#syntax#}error{#endsyntax#},
1121 returns {#syntax#}b{#endsyntax#} ("default value"),
1122 otherwise returns the unwrapped value of {#syntax#}a{#endsyntax#}.
1123 Note that {#syntax#}b{#endsyntax#} may be a value of type {#link|noreturn#}.
1124 {#syntax#}err{#endsyntax#} is the {#syntax#}error{#endsyntax#} and is in scope of the expression {#syntax#}b{#endsyntax#}.
11251125 </td>
11261126 <td>
1127 <pre><code class="zig">const value: error!u32 = error.Broken;
1127 <pre>{#syntax#}const value: error!u32 = error.Broken;
11281128const unwrapped = value catch 1234;
1129unwrapped == 1234</code></pre>
1129unwrapped == 1234{#endsyntax#}</pre>
11301130 </td>
11311131 </tr>
11321132 <tr>
1133 <td><pre><code class="zig">a and b<code></pre></td>
1133 <td><pre>{#syntax#}a and b{#endsyntax#}</pre></td>
11341134 <td>
11351135 <ul>
11361136 <li>{#link|bool|Primitive Types#}</li>
11371137 </ul>
11381138 </td>
11391139 <td>
1140 If <code>a</code> is <code>false</code>, returns <code>false</code>
1141 without evaluating <code>b</code>. Otherwise, returns <code>b</code>.
1140 If {#syntax#}a{#endsyntax#} is {#syntax#}false{#endsyntax#}, returns {#syntax#}false{#endsyntax#}
1141 without evaluating {#syntax#}b{#endsyntax#}. Otherwise, returns {#syntax#}b{#endsyntax#}.
11421142 </td>
11431143 <td>
1144 <pre><code class="zig">false and true == false</code></pre>
1144 <pre>{#syntax#}false and true == false{#endsyntax#}</pre>
11451145 </td>
11461146 </tr>
11471147 <tr>
1148 <td><pre><code class="zig">a or b<code></pre></td>
1148 <td><pre>{#syntax#}a or b{#endsyntax#}</pre></td>
11491149 <td>
11501150 <ul>
11511151 <li>{#link|bool|Primitive Types#}</li>
11521152 </ul>
11531153 </td>
11541154 <td>
1155 If <code>a</code> is <code>true</code>, returns <code>true</code>
1156 without evaluating <code>b</code>. Otherwise, returns <code>b</code>.
1155 If {#syntax#}a{#endsyntax#} is {#syntax#}true{#endsyntax#}, returns {#syntax#}true{#endsyntax#}
1156 without evaluating {#syntax#}b{#endsyntax#}. Otherwise, returns {#syntax#}b{#endsyntax#}.
11571157 </td>
11581158 <td>
1159 <pre><code class="zig">false or true == true</code></pre>
1159 <pre>{#syntax#}false or true == true{#endsyntax#}</pre>
11601160 </td>
11611161 </tr>
11621162 <tr>
1163 <td><pre><code class="zig">!a<code></pre></td>
1163 <td><pre>{#syntax#}!a{#endsyntax#}</pre></td>
11641164 <td>
11651165 <ul>
11661166 <li>{#link|bool|Primitive Types#}</li>
......@@ -1170,11 +1170,11 @@ unwrapped == 1234</code></pre>
11701170 Boolean NOT.
11711171 </td>
11721172 <td>
1173 <pre><code class="zig">!false == true</code></pre>
1173 <pre>{#syntax#}!false == true{#endsyntax#}</pre>
11741174 </td>
11751175 </tr>
11761176 <tr>
1177 <td><pre><code class="zig">a == b<code></pre></td>
1177 <td><pre>{#syntax#}a == b{#endsyntax#}</pre></td>
11781178 <td>
11791179 <ul>
11801180 <li>{#link|Integers#}</li>
......@@ -1184,30 +1184,30 @@ unwrapped == 1234</code></pre>
11841184 </ul>
11851185 </td>
11861186 <td>
1187 Returns <code>true</code> if a and b are equal, otherwise returns <code>false</code>.
1187 Returns {#syntax#}true{#endsyntax#} if a and b are equal, otherwise returns {#syntax#}false{#endsyntax#}.
11881188 Invokes {#link|Peer Type Resolution#} for the operands.
11891189 </td>
11901190 <td>
1191 <pre><code class="zig">(1 == 1) == true</code></pre>
1191 <pre>{#syntax#}(1 == 1) == true{#endsyntax#}</pre>
11921192 </td>
11931193 </tr>
11941194 <tr>
1195 <td><pre><code class="zig">a == null<code></pre></td>
1195 <td><pre>{#syntax#}a == null{#endsyntax#}</pre></td>
11961196 <td>
11971197 <ul>
11981198 <li>{#link|Optionals#}</li>
11991199 </ul>
12001200 </td>
12011201 <td>
1202 Returns <code>true</code> if a is <code>null</code>, otherwise returns <code>false</code>.
1202 Returns {#syntax#}true{#endsyntax#} if a is {#syntax#}null{#endsyntax#}, otherwise returns {#syntax#}false{#endsyntax#}.
12031203 </td>
12041204 <td>
1205 <pre><code class="zig">const value: ?u32 = null;
1206value == null</code></pre>
1205 <pre>{#syntax#}const value: ?u32 = null;
1206value == null{#endsyntax#}</pre>
12071207 </td>
12081208 </tr>
12091209 <tr>
1210 <td><pre><code class="zig">a != b<code></pre></td>
1210 <td><pre>{#syntax#}a != b{#endsyntax#}</pre></td>
12111211 <td>
12121212 <ul>
12131213 <li>{#link|Integers#}</li>
......@@ -1217,15 +1217,15 @@ value == null</code></pre>
12171217 </ul>
12181218 </td>
12191219 <td>
1220 Returns <code>false</code> if a and b are equal, otherwise returns <code>true</code>.
1220 Returns {#syntax#}false{#endsyntax#} if a and b are equal, otherwise returns {#syntax#}true{#endsyntax#}.
12211221 Invokes {#link|Peer Type Resolution#} for the operands.
12221222 </td>
12231223 <td>
1224 <pre><code class="zig">(1 != 1) == false</code></pre>
1224 <pre>{#syntax#}(1 != 1) == false{#endsyntax#}</pre>
12251225 </td>
12261226 </tr>
12271227 <tr>
1228 <td><pre><code class="zig">a &gt; b<code></pre></td>
1228 <td><pre>{#syntax#}a > b{#endsyntax#}</pre></td>
12291229 <td>
12301230 <ul>
12311231 <li>{#link|Integers#}</li>
......@@ -1233,15 +1233,15 @@ value == null</code></pre>
12331233 </ul>
12341234 </td>
12351235 <td>
1236 Returns <code>true</code> if a is greater than b, otherwise returns <code>false</code>.
1236 Returns {#syntax#}true{#endsyntax#} if a is greater than b, otherwise returns {#syntax#}false{#endsyntax#}.
12371237 Invokes {#link|Peer Type Resolution#} for the operands.
12381238 </td>
12391239 <td>
1240 <pre><code class="zig">(2 &gt; 1) == true</code></pre>
1240 <pre>{#syntax#}(2 > 1) == true{#endsyntax#}</pre>
12411241 </td>
12421242 </tr>
12431243 <tr>
1244 <td><pre><code class="zig">a &gt;= b<code></pre></td>
1244 <td><pre>{#syntax#}a >= b{#endsyntax#}</pre></td>
12451245 <td>
12461246 <ul>
12471247 <li>{#link|Integers#}</li>
......@@ -1249,15 +1249,15 @@ value == null</code></pre>
12491249 </ul>
12501250 </td>
12511251 <td>
1252 Returns <code>true</code> if a is greater than or equal to b, otherwise returns <code>false</code>.
1252 Returns {#syntax#}true{#endsyntax#} if a is greater than or equal to b, otherwise returns {#syntax#}false{#endsyntax#}.
12531253 Invokes {#link|Peer Type Resolution#} for the operands.
12541254 </td>
12551255 <td>
1256 <pre><code class="zig">(2 &gt;= 1) == true</code></pre>
1256 <pre>{#syntax#}(2 >= 1) == true{#endsyntax#}</pre>
12571257 </td>
12581258 </tr>
12591259 <tr>
1260 <td><pre><code class="zig">a &lt; b<code></pre></td>
1260 <td><pre>{#syntax#}a < b{#endsyntax#}</pre></td>
12611261 <td>
12621262 <ul>
12631263 <li>{#link|Integers#}</li>
......@@ -1265,15 +1265,15 @@ value == null</code></pre>
12651265 </ul>
12661266 </td>
12671267 <td>
1268 Returns <code>true</code> if a is less than b, otherwise returns <code>false</code>.
1268 Returns {#syntax#}true{#endsyntax#} if a is less than b, otherwise returns {#syntax#}false{#endsyntax#}.
12691269 Invokes {#link|Peer Type Resolution#} for the operands.
12701270 </td>
12711271 <td>
1272 <pre><code class="zig">(1 &lt; 2) == true</code></pre>
1272 <pre>{#syntax#}(1 < 2) == true{#endsyntax#}></pre>
12731273 </td>
12741274 </tr>
12751275 <tr>
1276 <td><pre><code class="zig">a &lt;= b<code></pre></td>
1276 <td><pre>{#syntax#}a <= b{#endsyntax#}</pre></td>
12771277 <td>
12781278 <ul>
12791279 <li>{#link|Integers#}</li>
......@@ -1281,15 +1281,15 @@ value == null</code></pre>
12811281 </ul>
12821282 </td>
12831283 <td>
1284 Returns <code>true</code> if a is less than or equal to b, otherwise returns <code>false</code>.
1284 Returns {#syntax#}true{#endsyntax#} if a is less than or equal to b, otherwise returns {#syntax#}false{#endsyntax#}.
12851285 Invokes {#link|Peer Type Resolution#} for the operands.
12861286 </td>
12871287 <td>
1288 <pre><code class="zig">(1 &lt;= 2) == true</code></pre>
1288 <pre>{#syntax#}(1 <= 2) == true{#endsyntax#}</pre>
12891289 </td>
12901290 </tr>
12911291 <tr>
1292 <td><pre><code class="zig">a ++ b<code></pre></td>
1292 <td><pre>{#syntax#}a ++ b{#endsyntax#}</pre></td>
12931293 <td>
12941294 <ul>
12951295 <li>{#link|Arrays#}</li>
......@@ -1298,19 +1298,19 @@ value == null</code></pre>
12981298 <td>
12991299 Array concatenation.
13001300 <ul>
1301 <li>Only available when <code>a</code> and <code>b</code> are {#link|compile-time known|comptime#}.
1301 <li>Only available when {#syntax#}a{#endsyntax#} and {#syntax#}b{#endsyntax#} are {#link|compile-time known|comptime#}.
13021302 </ul>
13031303 </td>
13041304 <td>
1305 <pre><code class="zig">const mem = @import("std").mem;
1305 <pre>{#syntax#}const mem = @import("std").mem;
13061306const array1 = []u32{1,2};
13071307const array2 = []u32{3,4};
13081308const together = array1 ++ array2;
1309mem.eql(u32, together, []u32{1,2,3,4})</code></pre>
1309mem.eql(u32, together, []u32{1,2,3,4}){#endsyntax#}</pre>
13101310 </td>
13111311 </tr>
13121312 <tr>
1313 <td><pre><code class="zig">a ** b<code></pre></td>
1313 <td><pre>{#syntax#}a ** b{#endsyntax#}</pre></td>
13141314 <td>
13151315 <ul>
13161316 <li>{#link|Arrays#}</li>
......@@ -1319,17 +1319,17 @@ mem.eql(u32, together, []u32{1,2,3,4})</code></pre>
13191319 <td>
13201320 Array multiplication.
13211321 <ul>
1322 <li>Only available when <code>a</code> and <code>b</code> are {#link|compile-time known|comptime#}.
1322 <li>Only available when {#syntax#}a{#endsyntax#} and {#syntax#}b{#endsyntax#} are {#link|compile-time known|comptime#}.
13231323 </ul>
13241324 </td>
13251325 <td>
1326 <pre><code class="zig">const mem = @import("std").mem;
1326 <pre>{#syntax#}const mem = @import("std").mem;
13271327const pattern = "ab" ** 3;
1328mem.eql(u8, pattern, "ababab")</code></pre>
1328mem.eql(u8, pattern, "ababab"){#endsyntax#}</pre>
13291329 </td>
13301330 </tr>
13311331 <tr>
1332 <td><pre><code class="zig">a.*<code></pre></td>
1332 <td><pre>{#syntax#}a.*{#endsyntax#}</pre></td>
13331333 <td>
13341334 <ul>
13351335 <li>{#link|Pointers#}</li>
......@@ -1339,13 +1339,13 @@ mem.eql(u8, pattern, "ababab")</code></pre>
13391339 Pointer dereference.
13401340 </td>
13411341 <td>
1342 <pre><code class="zig">const x: u32 = 1234;
1343const ptr = &amp;x;
1344x.* == 1234</code></pre>
1342 <pre>{#syntax#}const x: u32 = 1234;
1343const ptr = &x;
1344x.* == 1234{#endsyntax#}</pre>
13451345 </td>
13461346 </tr>
13471347 <tr>
1348 <td><pre><code class="zig">&amp;a<code></pre></td>
1348 <td><pre>{#syntax#}&amp;a{#endsyntax#}</pre></td>
13491349 <td>
13501350 All types
13511351 </td>
......@@ -1353,13 +1353,13 @@ x.* == 1234</code></pre>
13531353 Address of.
13541354 </td>
13551355 <td>
1356 <pre><code class="zig">const x: u32 = 1234;
1357const ptr = &amp;x;
1358x.* == 1234</code></pre>
1356 <pre>{#syntax#}const x: u32 = 1234;
1357const ptr = &x;
1358x.* == 1234{#endsyntax#}</pre>
13591359 </td>
13601360 </tr>
13611361 <tr>
1362 <td><pre><code class="zig">a || b<code></pre></td>
1362 <td><pre>{#syntax#}a || b{#endsyntax#}</pre></td>
13631363 <td>
13641364 <ul>
13651365 <li>{#link|Error Set Type#}</li>
......@@ -1369,30 +1369,30 @@ x.* == 1234</code></pre>
13691369 {#link|Merging Error Sets#}
13701370 </td>
13711371 <td>
1372 <pre><code class="zig">const A = error{One};
1372 <pre>{#syntax#}const A = error{One};
13731373const B = error{Two};
1374(A || B) == error{One, Two}</code></pre>
1374(A || B) == error{One, Two}{#endsyntax#}</pre>
13751375 </td>
13761376 </tr>
13771377 </table>
13781378 </div>
13791379 {#header_close#}
13801380 {#header_open|Precedence#}
1381 <pre><code>x() x[] x.y
1381 <pre>{#syntax#}x() x[] x.y
13821382a!b
1383!x -x -%x ~x &amp;x ?x
1383!x -x -%x ~x &x ?x
13841384x{} x.* x.?
13851385! * / % ** *% ||
13861386+ - ++ +% -%
1387&lt;&lt; &gt;&gt;
1388&amp;
1387<< >>
1388&
13891389^
13901390|
1391== != &lt; &gt; &lt;= &gt;=
1391== != < > <= >=
13921392and
13931393or
13941394orelse catch
1395= *= /= %= += -= &lt;&lt;= &gt;&gt;= &amp;= ^= |=</code></pre>
1395= *= /= %= += -= <<= >>= &= ^= |={#endsyntax#}</pre>
13961396 {#header_close#}
13971397 {#header_close#}
13981398 {#header_open|Arrays#}
......@@ -1641,7 +1641,7 @@ test "pointer child type" {
16411641 </p>
16421642 <p>
16431643 Alignment depends on the CPU architecture, but is always a power of two, and
1644 less than <code>1 &lt;&lt; 29</code>.
1644 less than {#syntax#}1 << 29{#endsyntax#}.
16451645 </p>
16461646 <p>
16471647 In Zig, a pointer type has an alignment value. If the value is equal to the
......@@ -1661,8 +1661,8 @@ test "variable alignment" {
16611661 }
16621662}
16631663 {#code_end#}
1664 <p>In the same way that a <code>*i32</code> can be {#link|implicitly cast|Implicit Casts#} to a
1665 <code>*const i32</code>, a pointer with a larger alignment can be implicitly
1664 <p>In the same way that a {#syntax#}*i32{#endsyntax#} can be {#link|implicitly cast|Implicit Casts#} to a
1665 {#syntax#}*const i32{#endsyntax#}, a pointer with a larger alignment can be implicitly
16661666 cast to a pointer with a smaller alignment, but not vice versa.
16671667 </p>
16681668 <p>
......@@ -1717,14 +1717,14 @@ fn foo(bytes: []u8) u32 {
17171717 {#header_open|Type Based Alias Analysis#}
17181718 <p>Zig uses Type Based Alias Analysis (also known as Strict Aliasing) to
17191719 perform some optimizations. This means that pointers of different types must
1720 not alias the same memory, with the exception of <code>u8</code>. Pointers to
1721 <code>u8</code> can alias any memory.
1720 not alias the same memory, with the exception of {#syntax#}u8{#endsyntax#}. Pointers to
1721 {#syntax#}u8{#endsyntax#} can alias any memory.
17221722 </p>
17231723 <p>As an example, this code produces undefined behavior:</p>
1724 <pre><code class="zig">@ptrCast(*u32, f32(12.34)).*</code></pre>
1724 <pre>{#syntax#}@ptrCast(*u32, f32(12.34)).*{#endsyntax#}</pre>
17251725 <p>Instead, use {#link|@bitCast#}:
1726 <pre><code class="zig">@bitCast(u32, f32(12.34))</code></pre>
1727 <p>As an added benefit, the <code>@bitCast</code> version works at compile-time.</p>
1726 <pre>{#syntax#}@bitCast(u32, f32(12.34)){#endsyntax#}</pre>
1727 <p>As an added benefit, the {#syntax#}@bitCast{#endsyntax#} version works at compile-time.</p>
17281728 {#see_also|Slices|Memory#}
17291729 {#header_close#}
17301730 {#header_close#}
......@@ -1952,9 +1952,9 @@ test "linked list" {
19521952 <ul>
19531953 <li>If the struct is in the initialization expression of a variable, it gets named after
19541954 that variable.</li>
1955 <li>If the struct is in the <code>return</code> expression, it gets named after
1955 <li>If the struct is in the {#syntax#}return{#endsyntax#} expression, it gets named after
19561956 the function it is returning from, with the parameter values serialized.</li>
1957 <li>Otherwise, the struct gets a same such as <code>(anonymous struct at file.zig:7:38)</code>.</li>
1957 <li>Otherwise, the struct gets a same such as {#syntax#}(anonymous struct at file.zig:7:38){#endsyntax#}.</li>
19581958 </ul>
19591959 {#code_begin|exe|struct_name#}
19601960const std = @import("std");
......@@ -2086,7 +2086,7 @@ const Foo = enum { A, B, C };
20862086export fn entry(foo: Foo) void { }
20872087 {#code_end#}
20882088 <p>
2089 For a C-ABI-compatible enum, use <code class="zig">extern enum</code>:
2089 For a C-ABI-compatible enum, use {#syntax#}extern enum{#endsyntax#}:
20902090 </p>
20912091 {#code_begin|obj#}
20922092const Foo = extern enum { A, B, C };
......@@ -2095,7 +2095,7 @@ export fn entry(foo: Foo) void { }
20952095 {#header_close#}
20962096 {#header_open|packed enum#}
20972097 <p>By default, the size of enums is not guaranteed.</p>
2098 <p><code>packed enum</code> causes the size of the enum to be the same as the size of the integer tag type
2098 <p>{#syntax#}packed enum{#endsyntax#} causes the size of the enum to be the same as the size of the integer tag type
20992099 of the enum:</p>
21002100 {#code_begin|test#}
21012101const std = @import("std");
......@@ -2246,7 +2246,7 @@ test "access variable after block scope" {
22462246 x += 1;
22472247}
22482248 {#code_end#}
2249 <p>Blocks are expressions. When labeled, <code>break</code> can be used
2249 <p>Blocks are expressions. When labeled, {#syntax#}break{#endsyntax#} can be used
22502250 to return a value from the block:
22512251 </p>
22522252 {#code_begin|test#}
......@@ -2264,7 +2264,7 @@ test "labeled break from labeled block expression" {
22642264 assert(y == 124);
22652265}
22662266 {#code_end#}
2267 <p>Here, <code>blk</code> can be any name.</p>
2267 <p>Here, {#syntax#}blk{#endsyntax#} can be any name.</p>
22682268 {#see_also|Labeled while|Labeled for#}
22692269 {#header_close#}
22702270 {#header_open|switch#}
......@@ -2380,7 +2380,7 @@ test "while basic" {
23802380}
23812381 {#code_end#}
23822382 <p>
2383 Use <code>break</code> to exit a while loop early.
2383 Use {#syntax#}break{#endsyntax#} to exit a while loop early.
23842384 </p>
23852385 {#code_begin|test|while#}
23862386const assert = @import("std").debug.assert;
......@@ -2396,7 +2396,7 @@ test "while break" {
23962396}
23972397 {#code_end#}
23982398 <p>
2399 Use <code>continue</code> to jump back to the beginning of the loop.
2399 Use {#syntax#}continue{#endsyntax#} to jump back to the beginning of the loop.
24002400 </p>
24012401 {#code_begin|test|while#}
24022402const assert = @import("std").debug.assert;
......@@ -2414,7 +2414,7 @@ test "while continue" {
24142414 {#code_end#}
24152415 <p>
24162416 While loops support a continue expression which is executed when the loop
2417 is continued. The <code>continue</code> keyword respects this expression.
2417 is continued. The {#syntax#}continue{#endsyntax#} keyword respects this expression.
24182418 </p>
24192419 {#code_begin|test|while#}
24202420const assert = @import("std").debug.assert;
......@@ -2436,13 +2436,13 @@ test "while loop continue expression, more complicated" {
24362436 {#code_end#}
24372437 <p>
24382438 While loops are expressions. The result of the expression is the
2439 result of the <code>else</code> clause of a while loop, which is executed when
2439 result of the {#syntax#}else{#endsyntax#} clause of a while loop, which is executed when
24402440 the condition of the while loop is tested as false.
24412441 </p>
24422442 <p>
2443 <code>break</code>, like <code>return</code>, accepts a value
2444 parameter. This is the result of the <code>while</code> expression.
2445 When you <code>break</code> from a while loop, the <code>else</code> branch is not
2443 {#syntax#}break{#endsyntax#}, like {#syntax#}return{#endsyntax#}, accepts a value
2444 parameter. This is the result of the {#syntax#}while{#endsyntax#} expression.
2445 When you {#syntax#}break{#endsyntax#} from a while loop, the {#syntax#}else{#endsyntax#} branch is not
24462446 evaluated.
24472447 </p>
24482448 {#code_begin|test|while#}
......@@ -2463,8 +2463,8 @@ fn rangeHasNumber(begin: usize, end: usize, number: usize) bool {
24632463}
24642464 {#code_end#}
24652465 {#header_open|Labeled while#}
2466 <p>When a <code>while</code> loop is labeled, it can be referenced from a <code>break</code>
2467 or <code>continue</code> from within a nested loop:</p>
2466 <p>When a {#syntax#}while{#endsyntax#} loop is labeled, it can be referenced from a {#syntax#}break{#endsyntax#}
2467 or {#syntax#}continue{#endsyntax#} from within a nested loop:</p>
24682468 {#code_begin|test#}
24692469test "nested break" {
24702470 outer: while (true) {
......@@ -2491,11 +2491,11 @@ test "nested continue" {
24912491 exits.
24922492 </p>
24932493 <p>
2494 When the <code>|x|</code> syntax is present on a <code>while</code> expression,
2494 When the {#syntax#}|x|{#endsyntax#} syntax is present on a {#syntax#}while{#endsyntax#} expression,
24952495 the while condition must have an {#link|Optional Type#}.
24962496 </p>
24972497 <p>
2498 The <code>else</code> branch is allowed on optional iteration. In this case, it will
2498 The {#syntax#}else{#endsyntax#} branch is allowed on optional iteration. In this case, it will
24992499 be executed on the first null value encountered.
25002500 </p>
25012501 {#code_begin|test|while#}
......@@ -2537,7 +2537,7 @@ fn eventuallyNullSequence() ?u32 {
25372537 the loop is finished.
25382538 </p>
25392539 <p>
2540 When the <code>else |x|</code> syntax is present on a <code>while</code> expression,
2540 When the {#syntax#}else |x|{#endsyntax#} syntax is present on a {#syntax#}while{#endsyntax#} expression,
25412541 the while condition must have an {#link|Error Union Type#}.
25422542 </p>
25432543 {#code_begin|test|while#}
......@@ -2593,7 +2593,7 @@ fn typeNameLength(comptime T: type) usize {
25932593}
25942594 {#code_end#}
25952595 <p>
2596 It is recommended to use <code>inline</code> loops only for one of these reasons:
2596 It is recommended to use {#syntax#}inline{#endsyntax#} loops only for one of these reasons:
25972597 </p>
25982598 <ul>
25992599 <li>You need the loop to execute at {#link|comptime#} for the semantics to work.</li>
......@@ -2671,8 +2671,8 @@ test "for else" {
26712671}
26722672 {#code_end#}
26732673 {#header_open|Labeled for#}
2674 <p>When a <code>for</code> loop is labeled, it can be referenced from a <code>break</code>
2675 or <code>continue</code> from within a nested loop:</p>
2674 <p>When a {#syntax#}for{#endsyntax#} loop is labeled, it can be referenced from a {#syntax#}break{#endsyntax#}
2675 or {#syntax#}continue{#endsyntax#} from within a nested loop:</p>
26762676 {#code_begin|test#}
26772677const std = @import("std");
26782678const assert = std.debug.assert;
......@@ -2732,7 +2732,7 @@ fn typeNameLength(comptime T: type) usize {
27322732}
27332733 {#code_end#}
27342734 <p>
2735 It is recommended to use <code>inline</code> loops only for one of these reasons:
2735 It is recommended to use {#syntax#}inline{#endsyntax#} loops only for one of these reasons:
27362736 </p>
27372737 <ul>
27382738 <li>You need the loop to execute at {#link|comptime#} for the semantics to work.</li>
......@@ -2932,13 +2932,13 @@ test "errdefer unwinding" {
29322932 {#header_close#}
29332933 {#header_open|unreachable#}
29342934 <p>
2935 In <code>Debug</code> and <code>ReleaseSafe</code> mode, and when using <code>zig test</code>,
2936 <code>unreachable</code> emits a call to <code>panic</code> with the message <code>reached unreachable code</code>.
2935 In {#syntax#}Debug{#endsyntax#} and {#syntax#}ReleaseSafe{#endsyntax#} mode, and when using <code>zig test</code>,
2936 {#syntax#}unreachable{#endsyntax#} emits a call to {#syntax#}panic{#endsyntax#} with the message <code>reached unreachable code</code>.
29372937 </p>
29382938 <p>
2939 In <code>ReleaseFast</code> mode, the optimizer uses the assumption that <code>unreachable</code> code
2940 will never be hit to perform optimizations. However, <code>zig test</code> even in <code>ReleaseFast</code> mode
2941 still emits <code>unreachable</code> as calls to <code>panic</code>.
2939 In {#syntax#}ReleaseFast{#endsyntax#} mode, the optimizer uses the assumption that {#syntax#}unreachable{#endsyntax#} code
2940 will never be hit to perform optimizations. However, <code>zig test</code> even in {#syntax#}ReleaseFast{#endsyntax#} mode
2941 still emits {#syntax#}unreachable{#endsyntax#} as calls to {#syntax#}panic{#endsyntax#}.
29422942 </p>
29432943 {#header_open|Basics#}
29442944 {#code_begin|test#}
......@@ -2984,17 +2984,17 @@ test "type of unreachable" {
29842984 {#header_close#}
29852985 {#header_open|noreturn#}
29862986 <p>
2987 <code>noreturn</code> is the type of:
2987 {#syntax#}noreturn{#endsyntax#} is the type of:
29882988 </p>
29892989 <ul>
2990 <li><code>break</code></li>
2991 <li><code>continue</code></li>
2992 <li><code>return</code></li>
2993 <li><code>unreachable</code></li>
2994 <li><code>while (true) {}</code></li>
2990 <li>{#syntax#}break{#endsyntax#}</li>
2991 <li>{#syntax#}continue{#endsyntax#}</li>
2992 <li>{#syntax#}return{#endsyntax#}</li>
2993 <li>{#syntax#}unreachable{#endsyntax#}</li>
2994 <li>{#syntax#}while (true) {}{#endsyntax#}</li>
29952995 </ul>
2996 <p>When resolving types together, such as <code>if</code> clauses or <code>switch</code> prongs,
2997 the <code>noreturn</code> type is compatible with every other type. Consider:
2996 <p>When resolving types together, such as {#syntax#}if{#endsyntax#} clauses or {#syntax#}switch{#endsyntax#} prongs,
2997 the {#syntax#}noreturn{#endsyntax#} type is compatible with every other type. Consider:
29982998 </p>
29992999 {#code_begin|test#}
30003000fn foo(condition: bool, b: u32) void {
......@@ -3005,7 +3005,7 @@ test "noreturn" {
30053005 foo(false, 1);
30063006}
30073007 {#code_end#}
3008 <p>Another use case for <code>noreturn</code> is the <code>exit</code> function:</p>
3008 <p>Another use case for {#syntax#}noreturn{#endsyntax#} is the {#syntax#}exit{#endsyntax#} function:</p>
30093009 {#code_begin|test#}
30103010 {#target_windows#}
30113011pub extern "kernel32" stdcallcc fn ExitProcess(exit_code: c_uint) noreturn;
......@@ -3134,7 +3134,7 @@ test "fn reflection" {
31343134 </p>
31353135 <p>
31363136 The number of unique error values across the entire compilation should determine the size of the error set type.
3137 However right now it is hard coded to be a <code>u16</code>. See <a href="https://github.com/ziglang/zig/issues/786">#768</a>.
3137 However right now it is hard coded to be a {#syntax#}u16{#endsyntax#}. See <a href="https://github.com/ziglang/zig/issues/786">#768</a>.
31383138 </p>
31393139 <p>
31403140 You can {#link|implicitly cast|Implicit Casts#} an error from a subset to its superset:
......@@ -3197,7 +3197,7 @@ const err = (error {FileNotFound}).FileNotFound;
31973197 This becomes useful when using {#link|Inferred Error Sets#}.
31983198 </p>
31993199 {#header_open|The Global Error Set#}
3200 <p><code>error</code> refers to the global error set.
3200 <p>{#syntax#}error{#endsyntax#} refers to the global error set.
32013201 This is the error set that contains all errors in the entire compilation unit.
32023202 It is a superset of all other error sets and a subset of none of them.
32033203 </p>
......@@ -3216,7 +3216,7 @@ const err = (error {FileNotFound}).FileNotFound;
32163216 {#header_close#}
32173217 {#header_open|Error Union Type#}
32183218 <p>
3219 An error set type and normal type can be combined with the <code>!</code>
3219 An error set type and normal type can be combined with the {#syntax#}!{#endsyntax#}
32203220 binary operator to form an error union type. You are likely to use an
32213221 error union type more often than an error set type by itself.
32223222 </p>
......@@ -3263,14 +3263,14 @@ test "parse u64" {
32633263}
32643264 {#code_end#}
32653265 <p>
3266 Notice the return type is <code>!u64</code>. This means that the function
3266 Notice the return type is {#syntax#}!u64{#endsyntax#}. This means that the function
32673267 either returns an unsigned 64 bit integer, or an error. We left off the error set
3268 to the left of the <code>!</code>, so the error set is inferred.
3268 to the left of the {#syntax#}!{#endsyntax#}, so the error set is inferred.
32693269 </p>
32703270 <p>
32713271 Within the function definition, you can see some return statements that return
3272 an error, and at the bottom a return statement that returns a <code>u64</code>.
3273 Both types {#link|implicitly cast|Implicit Casts#} to <code>error!u64</code>.
3272 an error, and at the bottom a return statement that returns a {#syntax#}u64{#endsyntax#}.
3273 Both types {#link|implicitly cast|Implicit Casts#} to {#syntax#}error!u64{#endsyntax#}.
32743274 </p>
32753275 <p>
32763276 What it looks like to use this function varies depending on what you're
......@@ -3283,7 +3283,7 @@ test "parse u64" {
32833283 <li>You want to take a different action for each possible error.</li>
32843284 </ul>
32853285 {#header_open|catch#}
3286 <p>If you want to provide a default value, you can use the <code>catch</code> binary operator:</p>
3286 <p>If you want to provide a default value, you can use the {#syntax#}catch{#endsyntax#} binary operator:</p>
32873287 {#code_begin|syntax#}
32883288fn doAThing(str: []u8) void {
32893289 const number = parseU64(str, 10) catch 13;
......@@ -3291,9 +3291,9 @@ fn doAThing(str: []u8) void {
32913291}
32923292 {#code_end#}
32933293 <p>
3294 In this code, <code>number</code> will be equal to the successfully parsed string, or
3295 a default value of 13. The type of the right hand side of the binary <code>catch</code> operator must
3296 match the unwrapped error union type, or be of type <code>noreturn</code>.
3294 In this code, {#syntax#}number{#endsyntax#} will be equal to the successfully parsed string, or
3295 a default value of 13. The type of the right hand side of the binary {#syntax#}catch{#endsyntax#} operator must
3296 match the unwrapped error union type, or be of type {#syntax#}noreturn{#endsyntax#}.
32973297 </p>
32983298 {#header_close#}
32993299 {#header_open|try#}
......@@ -3306,7 +3306,7 @@ fn doAThing(str: []u8) !void {
33063306}
33073307 {#code_end#}
33083308 <p>
3309 There is a shortcut for this. The <code>try</code> expression:
3309 There is a shortcut for this. The {#syntax#}try{#endsyntax#} expression:
33103310 </p>
33113311 {#code_begin|syntax#}
33123312fn doAThing(str: []u8) !void {
......@@ -3315,7 +3315,7 @@ fn doAThing(str: []u8) !void {
33153315}
33163316 {#code_end#}
33173317 <p>
3318 <code>try</code> evaluates an error union expression. If it is an error, it returns
3318 {#syntax#}try{#endsyntax#} evaluates an error union expression. If it is an error, it returns
33193319 from the current function with the same error. Otherwise, the expression results in
33203320 the unwrapped value.
33213321 </p>
......@@ -3327,7 +3327,7 @@ fn doAThing(str: []u8) !void {
33273327 {#code_begin|syntax#}const number = parseU64("1234", 10) catch unreachable;{#code_end#}
33283328 <p>
33293329 Here we know for sure that "1234" will parse successfully. So we put the
3330 <code>unreachable</code> value on the right hand side. <code>unreachable</code> generates
3330 {#syntax#}unreachable{#endsyntax#} value on the right hand side. {#syntax#}unreachable{#endsyntax#} generates
33313331 a panic in Debug and ReleaseSafe modes and undefined behavior in ReleaseFast mode. So, while we're debugging the
33323332 application, if there <em>was</em> a surprise error here, the application would crash
33333333 appropriately.
......@@ -3352,7 +3352,7 @@ fn doAThing(str: []u8) void {
33523352 {#header_open|errdefer#}
33533353 <p>
33543354 The other component to error handling is defer statements.
3355 In addition to an unconditional {#link|defer#}, Zig has <code>errdefer</code>,
3355 In addition to an unconditional {#link|defer#}, Zig has {#syntax#}errdefer{#endsyntax#},
33563356 which evaluates the deferred expression on block exit path if and only if
33573357 the function returned with an error from the block.
33583358 </p>
......@@ -3390,7 +3390,7 @@ fn createFoo(param: i32) !Foo {
33903390 <ul>
33913391 <li>These primitives give enough expressiveness that it's completely practical
33923392 to have failing to check for an error be a compile error. If you really want
3393 to ignore the error, you can add <code>catch unreachable</code> and
3393 to ignore the error, you can add {#syntax#}catch unreachable{#endsyntax#} and
33943394 get the added benefit of crashing in Debug and ReleaseSafe modes if your assumption was wrong.
33953395 </li>
33963396 <li>
......@@ -3401,7 +3401,7 @@ fn createFoo(param: i32) !Foo {
34013401 </ul>
34023402 {#see_also|defer|if|switch#}
34033403
3404 <p>An error union is created with the <code>!</code> binary operator.
3404 <p>An error union is created with the {#syntax#}!{#endsyntax#} binary operator.
34053405 You can use compile-time reflection to access the child type of an error union:</p>
34063406 {#code_begin|test#}
34073407const assert = @import("std").debug.assert;
......@@ -3424,15 +3424,15 @@ test "error union" {
34243424 {#code_end#}
34253425 {#header_open|Merging Error Sets#}
34263426 <p>
3427 Use the <code>||</code> operator to merge two error sets together. The resulting
3427 Use the {#syntax#}||{#endsyntax#} operator to merge two error sets together. The resulting
34283428 error set contains the errors of both error sets. Doc comments from the left-hand
34293429 side override doc comments from the right-hand side. In this example, the doc
3430 comments for <code>C.PathNotFound</code> is <code>A doc comment</code>.
3430 comments for {#syntax#}C.PathNotFound{#endsyntax#} is <code>A doc comment</code>.
34313431 </p>
34323432 <p>
34333433 This is especially useful for functions which return different error sets depending
34343434 on {#link|comptime#} branches. For example, the Zig standard library uses
3435 <code>LinuxFileOpenError || WindowsFileOpenError</code> for the error set of opening
3435 {#syntax#}LinuxFileOpenError || WindowsFileOpenError{#endsyntax#} for the error set of opening
34363436 files.
34373437 </p>
34383438 {#code_begin|test#}
......@@ -3565,8 +3565,8 @@ fn bang2() !void {
35653565 Look closely at this example. This is no stack trace.
35663566 </p>
35673567 <p>
3568 You can see that the final error bubbled up was <code>PermissionDenied</code>,
3569 but the original error that started this whole thing was <code>FileNotFound</code>. In the <code>bar</code> function, the code handles the original error code,
3568 You can see that the final error bubbled up was {#syntax#}PermissionDenied{#endsyntax#},
3569 but the original error that started this whole thing was {#syntax#}FileNotFound{#endsyntax#}. In the {#syntax#}bar{#endsyntax#} function, the code handles the original error code,
35703570 and then returns another one, from the switch statement. Error Return Traces make this clear, whereas a stack trace would look like this:
35713571 </p>
35723572 {#code_begin|exe_err#}
......@@ -3612,7 +3612,7 @@ fn bang2() void {
36123612 {#code_end#}
36133613 <p>
36143614 Here, the stack trace does not explain how the control
3615 flow in <code>bar</code> got to the <code>hello()</code> call.
3615 flow in {#syntax#}bar{#endsyntax#} got to the {#syntax#}hello(){#endsyntax#} call.
36163616 One would have to open a debugger or further instrument the application
36173617 in order to find out. The error return trace, on the other hand,
36183618 shows exactly how the error bubbled up.
......@@ -3631,8 +3631,8 @@ fn bang2() void {
36313631 </p>
36323632 <ul>
36333633 <li>Return an error from main</li>
3634 <li>An error makes its way to <code>catch unreachable</code> and you have not overridden the default panic handler</li>
3635 <li>Use {#link|errorReturnTrace#} to access the current return trace. You can use <code>std.debug.dumpStackTrace</code> to print it. This function returns comptime-known {#link|null#} when building without error return tracing support.</li>
3634 <li>An error makes its way to {#syntax#}catch unreachable{#endsyntax#} and you have not overridden the default panic handler</li>
3635 <li>Use {#link|errorReturnTrace#} to access the current return trace. You can use {#syntax#}std.debug.dumpStackTrace{#endsyntax#} to print it. This function returns comptime-known {#link|null#} when building without error return tracing support.</li>
36363636 </ul>
36373637 {#header_open|Implementation Details#}
36383638 <p>
......@@ -3643,7 +3643,7 @@ fn bang2() void {
36433643 <li>when returning errors</li>
36443644 </ul>
36453645 <p>
3646 For the case when no errors are returned, the cost is a single memory write operation, only in the first non-failable function in the call graph that calls a failable function, i.e. when a function returning <code>void</code> calls a function returning <code>error</code>.
3646 For the case when no errors are returned, the cost is a single memory write operation, only in the first non-failable function in the call graph that calls a failable function, i.e. when a function returning {#syntax#}void{#endsyntax#} calls a function returning {#syntax#}error{#endsyntax#}.
36473647 This is to initialize this struct in the stack memory:
36483648 </p>
36493649 {#code_begin|syntax#}
......@@ -3656,13 +3656,13 @@ pub const StackTrace = struct {
36563656 Here, N is the maximum function call depth as determined by call graph analysis. Recursion is ignored and counts for 2.
36573657 </p>
36583658 <p>
3659 A pointer to <code>StackTrace</code> is passed as a secret parameter to every function that can return an error, but it's always the first parameter, so it can likely sit in a register and stay there.
3659 A pointer to {#syntax#}StackTrace{#endsyntax#} is passed as a secret parameter to every function that can return an error, but it's always the first parameter, so it can likely sit in a register and stay there.
36603660 </p>
36613661 <p>
36623662 That's it for the path when no errors occur. It's practically free in terms of performance.
36633663 </p>
36643664 <p>
3665 When generating the code for a function that returns an error, just before the <code>return</code> statement (only for the <code>return</code> statements that return errors), Zig generates a call to this function:
3665 When generating the code for a function that returns an error, just before the {#syntax#}return{#endsyntax#} statement (only for the {#syntax#}return{#endsyntax#} statements that return errors), Zig generates a call to this function:
36663666 </p>
36673667 {#code_begin|syntax#}
36683668// marked as "no-inline" in LLVM IR
......@@ -3677,7 +3677,7 @@ fn __zig_return_error(stack_trace: *StackTrace) void {
36773677 <p>
36783678 As for code size cost, 1 function call before a return statement is no big deal. Even so,
36793679 I have <a href="https://github.com/ziglang/zig/issues/690">a plan</a> to make the call to
3680 <code>__zig_return_error</code> a tail call, which brings the code size cost down to actually zero. What is a return statement in code without error return tracing can become a jump instruction in code with error return tracing.
3680 {#syntax#}__zig_return_error{#endsyntax#} a tail call, which brings the code size cost down to actually zero. What is a return statement in code without error return tracing can become a jump instruction in code with error return tracing.
36813681 </p>
36823682 {#header_close#}
36833683 {#header_close#}
......@@ -3699,7 +3699,7 @@ const normal_int: i32 = 1234;
36993699const optional_int: ?i32 = 5678;
37003700 {#code_end#}
37013701 <p>
3702 Now the variable <code>optional_int</code> could be an <code>i32</code>, or <code>null</code>.
3702 Now the variable {#syntax#}optional_int{#endsyntax#} could be an {#syntax#}i32{#endsyntax#}, or {#syntax#}null{#endsyntax#}.
37033703 </p>
37043704 <p>
37053705 Instead of integers, let's talk about pointers. Null references are the source of many runtime
......@@ -3740,8 +3740,8 @@ fn doAThing() ?*Foo {
37403740 {#code_end#}
37413741 <p>
37423742 Here, Zig is at least as convenient, if not more, than C. And, the type of "ptr"
3743 is <code>*u8</code> <em>not</em> <code>?*u8</code>. The <code>orelse</code> keyword
3744 unwrapped the optional type and therefore <code>ptr</code> is guaranteed to be non-null everywhere
3743 is {#syntax#}*u8{#endsyntax#} <em>not</em> {#syntax#}?*u8{#endsyntax#}. The {#syntax#}orelse{#endsyntax#} keyword
3744 unwrapped the optional type and therefore {#syntax#}ptr{#endsyntax#} is guaranteed to be non-null everywhere
37453745 it is used in the function.
37463746 </p>
37473747 <p>
......@@ -3772,7 +3772,7 @@ fn doAThing(optional_foo: ?*Foo) void {
37723772 {#code_end#}
37733773 <p>
37743774 Once again, the notable thing here is that inside the if block,
3775 <code>foo</code> is no longer an optional pointer, it is a pointer, which
3775 {#syntax#}foo{#endsyntax#} is no longer an optional pointer, it is a pointer, which
37763776 cannot be null.
37773777 </p>
37783778 <p>
......@@ -3783,7 +3783,7 @@ fn doAThing(optional_foo: ?*Foo) void {
37833783 cannot be null.
37843784 </p>
37853785 {#header_open|Optional Type#}
3786 <p>An optional is created by putting <code>?</code> in front of a type. You can use compile-time
3786 <p>An optional is created by putting {#syntax#}?{#endsyntax#} in front of a type. You can use compile-time
37873787 reflection to access the child type of an optional:</p>
37883788 {#code_begin|test#}
37893789const assert = @import("std").debug.assert;
......@@ -3802,7 +3802,7 @@ test "optional type" {
38023802 {#header_close#}
38033803 {#header_open|null#}
38043804 <p>
3805 Just like {#link|undefined#}, <code>null</code> has its own type, and the only way to use it is to
3805 Just like {#link|undefined#}, {#syntax#}null{#endsyntax#} has its own type, and the only way to use it is to
38063806 cast it to a different type:
38073807 </p>
38083808 {#code_begin|syntax#}
......@@ -3850,9 +3850,9 @@ test "implicit cast - invoke a type as a function" {
38503850 of the qualifiers, no matter how nested the qualifiers are:
38513851 </p>
38523852 <ul>
3853 <li><code>const</code> - non-const to const is allowed</li>
3854 <li><code>volatile</code> - non-volatile to volatile is allowed</li>
3855 <li><code>align</code> - bigger to smaller alignment is allowed </li>
3853 <li>{#syntax#}const{#endsyntax#} - non-const to const is allowed</li>
3854 <li>{#syntax#}volatile{#endsyntax#} - non-volatile to volatile is allowed</li>
3855 <li>{#syntax#}align{#endsyntax#} - bigger to smaller alignment is allowed </li>
38563856 <li>{#link|error sets|Error Set Type#} to supersets is allowed</li>
38573857 </ul>
38583858 <p>
......@@ -4100,7 +4100,7 @@ fn peerTypeEmptyArrayAndSliceAndError(a: bool, slice: []u8) error![]u8 {
41004100
41014101 {#header_open|void#}
41024102 <p>
4103 <code>void</code> represents a type that has no value. Code that makes use of void values is
4103 {#syntax#}void{#endsyntax#} represents a type that has no value. Code that makes use of void values is
41044104 not included in the final generated code:
41054105 </p>
41064106 {#code_begin|syntax#}
......@@ -4110,7 +4110,7 @@ export fn entry() void {
41104110 x = y;
41114111}
41124112 {#code_end#}
4113 <p>When this turns into LLVM IR, there is no code generated in the body of <code>entry</code>,
4113 <p>When this turns into LLVM IR, there is no code generated in the body of {#syntax#}entry{#endsyntax#},
41144114 even in debug mode. For example, on x86_64:</p>
41154115 <pre><code>0000000000000010 &lt;entry&gt;:
41164116 10: 55 push %rbp
......@@ -4120,9 +4120,9 @@ export fn entry() void {
41204120 <p>These assembly instructions do not have any code associated with the void values -
41214121 they only perform the function call prologue and epilog.</p>
41224122 <p>
4123 <code>void</code> can be useful for instantiating generic types. For example, given a
4124 <code>Map(Key, Value)</code>, one can pass <code>void</code> for the <code>Value</code>
4125 type to make it into a <code>Set</code>:
4123 {#syntax#}void{#endsyntax#} can be useful for instantiating generic types. For example, given a
4124 {#syntax#}Map(Key, Value){#endsyntax#}, one can pass {#syntax#}void{#endsyntax#} for the {#syntax#}Value{#endsyntax#}
4125 type to make it into a {#syntax#}Set{#endsyntax#}:
41264126 </p>
41274127 {#code_begin|test#}
41284128const std = @import("std");
......@@ -4151,17 +4151,17 @@ fn eql_i32(a: i32, b: i32) bool {
41514151}
41524152 {#code_end#}
41534153 <p>Note that this is different than using a dummy value for the hash map value.
4154 By using <code>void</code> as the type of the value, the hash map entry type has no value field, and
4154 By using {#syntax#}void{#endsyntax#} as the type of the value, the hash map entry type has no value field, and
41554155 thus the hash map takes up less space. Further, all the code that deals with storing and loading the
41564156 value is deleted, as seen above.
41574157 </p>
41584158 <p>
4159 <code>void</code> is distinct from <code>c_void</code>, which is defined like this:
4160 <code>pub const c_void = @OpaqueType();</code>.
4161 <code>void</code> has a known size of 0 bytes, and <code>c_void</code> has an unknown, but non-zero, size.
4159 {#syntax#}void{#endsyntax#} is distinct from {#syntax#}c_void{#endsyntax#}, which is defined like this:
4160 {#syntax#}pub const c_void = @OpaqueType();{#endsyntax#}.
4161 {#syntax#}void{#endsyntax#} has a known size of 0 bytes, and {#syntax#}c_void{#endsyntax#} has an unknown, but non-zero, size.
41624162 </p>
41634163 <p>
4164 Expressions of type <code>void</code> are the only ones whose value can be ignored. For example:
4164 Expressions of type {#syntax#}void{#endsyntax#} are the only ones whose value can be ignored. For example:
41654165 </p>
41664166 {#code_begin|test_err|expression value is ignored#}
41674167test "ignoring expression value" {
......@@ -4172,7 +4172,7 @@ fn foo() i32 {
41724172 return 1234;
41734173}
41744174 {#code_end#}
4175 <p>However, if the expression has type <code>void</code>:</p>
4175 <p>However, if the expression has type {#syntax#}void{#endsyntax#}:</p>
41764176 {#code_begin|test#}
41774177test "ignoring expression value" {
41784178 foo();
......@@ -4207,10 +4207,10 @@ fn gimmeTheBiggerInteger(a: u64, b: u64) u64 {
42074207 <p>
42084208 In Zig, types are first-class citizens. They can be assigned to variables, passed as parameters to functions,
42094209 and returned from functions. However, they can only be used in expressions which are known at <em>compile-time</em>,
4210 which is why the parameter <code>T</code> in the above snippet must be marked with <code>comptime</code>.
4210 which is why the parameter {#syntax#}T{#endsyntax#} in the above snippet must be marked with {#syntax#}comptime{#endsyntax#}.
42114211 </p>
42124212 <p>
4213 A <code>comptime</code> parameter means that:
4213 A {#syntax#}comptime{#endsyntax#} parameter means that:
42144214 </p>
42154215 <ul>
42164216 <li>At the callsite, the value must be known at compile-time, or it is a compile error.</li>
......@@ -4255,7 +4255,7 @@ test "try to compare bools" {
42554255}
42564256 {#code_end#}
42574257 <p>
4258 On the flip side, inside the function definition with the <code>comptime</code> parameter, the
4258 On the flip side, inside the function definition with the {#syntax#}comptime{#endsyntax#} parameter, the
42594259 value is known at compile-time. This means that we actually could make this work for the bool type
42604260 if we wanted to:
42614261 </p>
......@@ -4274,12 +4274,12 @@ test "try to compare bools" {
42744274}
42754275 {#code_end#}
42764276 <p>
4277 This works because Zig implicitly inlines <code>if</code> expressions when the condition
4277 This works because Zig implicitly inlines {#syntax#}if{#endsyntax#} expressions when the condition
42784278 is known at compile-time, and the compiler guarantees that it will skip analysis of
42794279 the branch not taken.
42804280 </p>
42814281 <p>
4282 This means that the actual function generated for <code>max</code> in this situation looks like
4282 This means that the actual function generated for {#syntax#}max{#endsyntax#} in this situation looks like
42834283 this:
42844284 </p>
42854285 {#code_begin|syntax#}
......@@ -4292,18 +4292,18 @@ fn max(a: bool, b: bool) bool {
42924292 the necessary run-time code to accomplish the task.
42934293 </p>
42944294 <p>
4295 This works the same way for <code>switch</code> expressions - they are implicitly inlined
4295 This works the same way for {#syntax#}switch{#endsyntax#} expressions - they are implicitly inlined
42964296 when the target expression is compile-time known.
42974297 </p>
42984298 {#header_close#}
42994299 {#header_open|Compile-Time Variables#}
43004300 <p>
4301 In Zig, the programmer can label variables as <code>comptime</code>. This guarantees to the compiler
4301 In Zig, the programmer can label variables as {#syntax#}comptime{#endsyntax#}. This guarantees to the compiler
43024302 that every load and store of the variable is performed at compile-time. Any violation of this results in a
43034303 compile error.
43044304 </p>
43054305 <p>
4306 This combined with the fact that we can <code>inline</code> loops allows us to write
4306 This combined with the fact that we can {#syntax#}inline{#endsyntax#} loops allows us to write
43074307 a function which is partially evaluated at compile-time and partially at run-time.
43084308 </p>
43094309 <p>
......@@ -4346,8 +4346,8 @@ test "perform fn" {
43464346 <p>
43474347 This example is a bit contrived, because the compile-time evaluation component is unnecessary;
43484348 this code would work fine if it was all done at run-time. But it does end up generating
4349 different code. In this example, the function <code>performFn</code> is generated three different times,
4350 for the different values of <code>prefix_char</code> provided:
4349 different code. In this example, the function {#syntax#}performFn{#endsyntax#} is generated three different times,
4350 for the different values of {#syntax#}prefix_char{#endsyntax#} provided:
43514351 </p>
43524352 {#code_begin|syntax#}
43534353// From the line:
......@@ -4388,7 +4388,7 @@ fn performFn(start_value: i32) i32 {
43884388 {#header_open|Compile-Time Expressions#}
43894389 <p>
43904390 In Zig, it matters whether a given expression is known at compile-time or run-time. A programmer can
4391 use a <code>comptime</code> expression to guarantee that the expression will be evaluated at compile-time.
4391 use a {#syntax#}comptime{#endsyntax#} expression to guarantee that the expression will be evaluated at compile-time.
43924392 If this cannot be accomplished, the compiler will emit an error. For example:
43934393 </p>
43944394 {#code_begin|test_err|unable to evaluate constant expression#}
......@@ -4401,16 +4401,16 @@ test "foo" {
44014401}
44024402 {#code_end#}
44034403 <p>
4404 It doesn't make sense that a program could call <code>exit()</code> (or any other external function)
4405 at compile-time, so this is a compile error. However, a <code>comptime</code> expression does much
4404 It doesn't make sense that a program could call {#syntax#}exit(){#endsyntax#} (or any other external function)
4405 at compile-time, so this is a compile error. However, a {#syntax#}comptime{#endsyntax#} expression does much
44064406 more than sometimes cause a compile error.
44074407 </p>
44084408 <p>
4409 Within a <code>comptime</code> expression:
4409 Within a {#syntax#}comptime{#endsyntax#} expression:
44104410 </p>
44114411 <ul>
4412 <li>All variables are <code>comptime</code> variables.</li>
4413 <li>All <code>if</code>, <code>while</code>, <code>for</code>, and <code>switch</code>
4412 <li>All variables are {#syntax#}comptime{#endsyntax#} variables.</li>
4413 <li>All {#syntax#}if{#endsyntax#}, {#syntax#}while{#endsyntax#}, {#syntax#}for{#endsyntax#}, and {#syntax#}switch{#endsyntax#}
44144414 expressions are evaluated at compile-time, or emit a compile error if this is not possible.</li>
44154415 <li>All function calls cause the compiler to interpret the function at compile-time, emitting a
44164416 compile error if the function tries to do something that has global run-time side effects.</li>
......@@ -4487,7 +4487,7 @@ test "fibonacci" {
44874487 {#link|@setEvalBranchQuota#} to change the default number 1000 to something else.
44884488 </p>
44894489 <p>
4490 What if we fix the base case, but put the wrong value in the <code>assert</code> line?
4490 What if we fix the base case, but put the wrong value in the {#syntax#}assert{#endsyntax#} line?
44914491 </p>
44924492 {#code_begin|test_err|encountered @panic at compile-time#}
44934493const assert = @import("std").debug.assert;
......@@ -4504,16 +4504,16 @@ test "fibonacci" {
45044504}
45054505 {#code_end#}
45064506 <p>
4507 What happened is Zig started interpreting the <code>assert</code> function with the
4508 parameter <code>ok</code> set to <code>false</code>. When the interpreter hit
4509 <code>unreachable</code> it emitted a compile error, because reaching unreachable
4507 What happened is Zig started interpreting the {#syntax#}assert{#endsyntax#} function with the
4508 parameter {#syntax#}ok{#endsyntax#} set to {#syntax#}false{#endsyntax#}. When the interpreter hit
4509 {#syntax#}unreachable{#endsyntax#} it emitted a compile error, because reaching unreachable
45104510 code is undefined behavior, and undefined behavior causes a compile error if it is detected
45114511 at compile-time.
45124512 </p>
45134513
45144514 <p>
45154515 In the global scope (outside of any function), all expressions are implicitly
4516 <code>comptime</code> expressions. This means that we can use functions to
4516 {#syntax#}comptime{#endsyntax#} expressions. This means that we can use functions to
45174517 initialize complex static data. For example:
45184518 </p>
45194519 {#code_begin|test#}
......@@ -4561,7 +4561,7 @@ test "variable values" {
45614561@1 = internal unnamed_addr constant i32 1060</code></pre>
45624562 <p>
45634563 Note that we did not have to do anything special with the syntax of these functions. For example,
4564 we could call the <code>sum</code> function as is with a slice of numbers whose length and values were
4564 we could call the {#syntax#}sum{#endsyntax#} function as is with a slice of numbers whose length and values were
45654565 only known at run-time.
45664566 </p>
45674567 {#header_close#}
......@@ -4573,8 +4573,8 @@ test "variable values" {
45734573 generic data structure.
45744574 </p>
45754575 <p>
4576 Here is an example of a generic <code>List</code> data structure, that we will instantiate with
4577 the type <code>i32</code>. In Zig we refer to the type as <code>List(i32)</code>.
4576 Here is an example of a generic {#syntax#}List{#endsyntax#} data structure, that we will instantiate with
4577 the type {#syntax#}i32{#endsyntax#}. In Zig we refer to the type as {#syntax#}List(i32){#endsyntax#}.
45784578 </p>
45794579 {#code_begin|syntax#}
45804580fn List(comptime T: type) type {
......@@ -4585,8 +4585,8 @@ fn List(comptime T: type) type {
45854585}
45864586 {#code_end#}
45874587 <p>
4588 That's it. It's a function that returns an anonymous <code>struct</code>. For the purposes of error messages
4589 and debugging, Zig infers the name <code>"List(i32)"</code> from the function name and parameters invoked when creating
4588 That's it. It's a function that returns an anonymous {#syntax#}struct{#endsyntax#}. For the purposes of error messages
4589 and debugging, Zig infers the name {#syntax#}"List(i32)"{#endsyntax#} from the function name and parameters invoked when creating
45904590 the anonymous struct.
45914591 </p>
45924592 <p>
......@@ -4602,13 +4602,13 @@ const Node = struct {
46024602 <p>
46034603 This works because all top level declarations are order-independent, and as long as there isn't
46044604 an actual infinite regression, values can refer to themselves, directly or indirectly. In this case,
4605 <code>Node</code> refers to itself as a pointer, which is not actually an infinite regression, so
4605 {#syntax#}Node{#endsyntax#} refers to itself as a pointer, which is not actually an infinite regression, so
46064606 it works fine.
46074607 </p>
46084608 {#header_close#}
46094609 {#header_open|Case Study: printf in Zig#}
46104610 <p>
4611 Putting all of this together, let's see how <code>printf</code> works in Zig.
4611 Putting all of this together, let's see how {#syntax#}printf{#endsyntax#} works in Zig.
46124612 </p>
46134613 {#code_begin|exe|printf#}
46144614const warn = @import("std").debug.warn;
......@@ -4709,7 +4709,7 @@ pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void {
47094709}
47104710 {#code_end#}
47114711 <p>
4712 <code>printValue</code> is a function that takes a parameter of any type, and does different things depending
4712 {#syntax#}printValue{#endsyntax#} is a function that takes a parameter of any type, and does different things depending
47134713 on the type:
47144714 </p>
47154715 {#code_begin|syntax#}
......@@ -4725,7 +4725,7 @@ pub fn printValue(self: *OutStream, value: var) !void {
47254725}
47264726 {#code_end#}
47274727 <p>
4728 And now, what happens if we give too many arguments to <code>printf</code>?
4728 And now, what happens if we give too many arguments to {#syntax#}printf{#endsyntax#}?
47294729 </p>
47304730 {#code_begin|test_err|Unused arguments#}
47314731const warn = @import("std").debug.warn;
......@@ -4743,7 +4743,7 @@ test "printf too many arguments" {
47434743 </p>
47444744 <p>
47454745 Zig doesn't care whether the format argument is a string literal,
4746 only that it is a compile-time known value that is implicitly castable to a <code>[]const u8</code>:
4746 only that it is a compile-time known value that is implicitly castable to a {#syntax#}[]const u8{#endsyntax#}:
47474747 </p>
47484748 {#code_begin|exe|printf#}
47494749const warn = @import("std").debug.warn;
......@@ -4797,16 +4797,16 @@ pub fn main() void {
47974797 </p>
47984798 {#header_open|Minimal Coroutine Example#}
47994799 <p>
4800 Declare a coroutine with the <code>async</code> keyword.
4800 Declare a coroutine with the {#syntax#}async{#endsyntax#} keyword.
48014801 The expression in angle brackets must evaluate to a struct
48024802 which has these fields:
48034803 </p>
48044804 <ul>
4805 <li><code>allocFn: fn (self: *Allocator, byte_count: usize, alignment: u29) Error![]u8</code> - where <code>Error</code> can be any error set.</li>
4806 <li><code>freeFn: fn (self: *Allocator, old_mem: []u8) void</code></li>
4805 <li>{#syntax#}allocFn: fn (self: *Allocator, byte_count: usize, alignment: u29) Error![]u8{#endsyntax#} - where {#syntax#}Error{#endsyntax#} can be any error set.</li>
4806 <li>{#syntax#}freeFn: fn (self: *Allocator, old_mem: []u8) void{#endsyntax#}</li>
48074807 </ul>
48084808 <p>
4809 You may notice that this corresponds to the <code>std.mem.Allocator</code> interface.
4809 You may notice that this corresponds to the {#syntax#}std.mem.Allocator{#endsyntax#} interface.
48104810 This makes it convenient to integrate with existing allocators. Note, however,
48114811 that the language feature does not depend on the standard library, and any struct which
48124812 has these fields is allowed.
......@@ -4816,13 +4816,13 @@ pub fn main() void {
48164816 the function generic. Zig will infer the allocator type when the async function is called.
48174817 </p>
48184818 <p>
4819 Call a coroutine with the <code>async</code> keyword. Here, the expression in angle brackets
4819 Call a coroutine with the {#syntax#}async{#endsyntax#} keyword. Here, the expression in angle brackets
48204820 is a pointer to the allocator struct that the coroutine expects.
48214821 </p>
48224822 <p>
4823 The result of an async function call is a <code>promise->T</code> type, where <code>T</code>
4823 The result of an async function call is a {#syntax#}promise->T{#endsyntax#} type, where {#syntax#}T{#endsyntax#}
48244824 is the return type of the async function. Once a promise has been created, it must be
4825 consumed, either with <code>cancel</code> or <code>await</code>:
4825 consumed, either with {#syntax#}cancel{#endsyntax#} or {#syntax#}await{#endsyntax#}:
48264826 </p>
48274827 <p>
48284828 Async functions start executing when created, so in the following example, the entire
......@@ -4911,18 +4911,18 @@ async fn testSuspendBlock() void {
49114911 {#code_end#}
49124912 <p>
49134913 Every suspend point in an async function represents a point at which the coroutine
4914 could be destroyed. If that happens, <code>defer</code> expressions that are in
4915 scope are run, as well as <code>errdefer</code> expressions.
4914 could be destroyed. If that happens, {#syntax#}defer{#endsyntax#} expressions that are in
4915 scope are run, as well as {#syntax#}errdefer{#endsyntax#} expressions.
49164916 </p>
49174917 <p>
49184918 {#link|Await#} counts as a suspend point.
49194919 </p>
49204920 {#header_open|Resuming from Suspend Blocks#}
49214921 <p>
4922 Upon entering a <code>suspend</code> block, the coroutine is already considered
4922 Upon entering a {#syntax#}suspend{#endsyntax#} block, the coroutine is already considered
49234923 suspended, and can be resumed. For example, if you started another kernel thread,
4924 and had that thread call <code>resume</code> on the promise handle provided by the
4925 <code>suspend</code> block, the new thread would begin executing after the suspend
4924 and had that thread call {#syntax#}resume{#endsyntax#} on the promise handle provided by the
4925 {#syntax#}suspend{#endsyntax#} block, the new thread would begin executing after the suspend
49264926 block, while the old thread continued executing the suspend block.
49274927 </p>
49284928 <p>
......@@ -4957,26 +4957,26 @@ async fn testResumeFromSuspend(my_result: *i32) void {
49574957 {#header_close#}
49584958 {#header_open|Await#}
49594959 <p>
4960 The <code>await</code> keyword is used to coordinate with an async function's
4961 <code>return</code> statement.
4960 The {#syntax#}await{#endsyntax#} keyword is used to coordinate with an async function's
4961 {#syntax#}return{#endsyntax#} statement.
49624962 </p>
49634963 <p>
4964 <code>await</code> is valid only in an <code>async</code> function, and it takes
4964 {#syntax#}await{#endsyntax#} is valid only in an {#syntax#}async{#endsyntax#} function, and it takes
49654965 as an operand a promise handle.
49664966 If the async function associated with the promise handle has already returned,
4967 then <code>await</code> destroys the target async function, and gives the return value.
4968 Otherwise, <code>await</code> suspends the current async function, registering its
4967 then {#syntax#}await{#endsyntax#} destroys the target async function, and gives the return value.
4968 Otherwise, {#syntax#}await{#endsyntax#} suspends the current async function, registering its
49694969 promise handle with the target coroutine. It becomes the target coroutine's responsibility
49704970 to have ensured that it will be resumed or destroyed. When the target coroutine reaches
49714971 its return statement, it gives the return value to the awaiter, destroys itself, and then
49724972 resumes the awaiter.
49734973 </p>
49744974 <p>
4975 A promise handle must be consumed exactly once after it is created, either by <code>cancel</code> or <code>await</code>.
4975 A promise handle must be consumed exactly once after it is created, either by {#syntax#}cancel{#endsyntax#} or {#syntax#}await{#endsyntax#}.
49764976 </p>
49774977 <p>
4978 <code>await</code> counts as a suspend point, and therefore at every <code>await</code>,
4979 a coroutine can be potentially destroyed, which would run <code>defer</code> and <code>errdefer</code> expressions.
4978 {#syntax#}await{#endsyntax#} counts as a suspend point, and therefore at every {#syntax#}await{#endsyntax#},
4979 a coroutine can be potentially destroyed, which would run {#syntax#}defer{#endsyntax#} and {#syntax#}errdefer{#endsyntax#} expressions.
49804980 </p>
49814981 {#code_begin|test#}
49824982const std = @import("std");
......@@ -5020,9 +5020,9 @@ fn seq(c: u8) void {
50205020}
50215021 {#code_end#}
50225022 <p>
5023 In general, <code>suspend</code> is lower level than <code>await</code>. Most application
5024 code will use only <code>async</code> and <code>await</code>, but event loop
5025 implementations will make use of <code>suspend</code> internally.
5023 In general, {#syntax#}suspend{#endsyntax#} is lower level than {#syntax#}await{#endsyntax#}. Most application
5024 code will use only {#syntax#}async{#endsyntax#} and {#syntax#}await{#endsyntax#}, but event loop
5025 implementations will make use of {#syntax#}suspend{#endsyntax#} internally.
50265026 </p>
50275027 {#header_close#}
50285028 {#header_open|Open Issues#}
......@@ -5052,36 +5052,36 @@ fn seq(c: u8) void {
50525052 {#header_open|Builtin Functions#}
50535053 <p>
50545054 Builtin functions are provided by the compiler and are prefixed with <code>@</code>.
5055 The <code>comptime</code> keyword on a parameter means that the parameter must be known
5055 The {#syntax#}comptime{#endsyntax#} keyword on a parameter means that the parameter must be known
50565056 at compile time.
50575057 </p>
50585058 {#header_open|@addWithOverflow#}
5059 <pre><code class="zig">@addWithOverflow(comptime T: type, a: T, b: T, result: *T) bool</code></pre>
5059 <pre>{#syntax#}@addWithOverflow(comptime T: type, a: T, b: T, result: *T) bool{#endsyntax#}</pre>
50605060 <p>
5061 Performs <code>result.* = a + b</code>. If overflow or underflow occurs,
5062 stores the overflowed bits in <code>result</code> and returns <code>true</code>.
5063 If no overflow or underflow occurs, returns <code>false</code>.
5061 Performs {#syntax#}result.* = a + b{#endsyntax#}. If overflow or underflow occurs,
5062 stores the overflowed bits in {#syntax#}result{#endsyntax#} and returns {#syntax#}true{#endsyntax#}.
5063 If no overflow or underflow occurs, returns {#syntax#}false{#endsyntax#}.
50645064 </p>
50655065 {#header_close#}
50665066 {#header_open|@ArgType#}
5067 <pre><code class="zig">@ArgType(comptime T: type, comptime n: usize) type</code></pre>
5067 <pre>{#syntax#}@ArgType(comptime T: type, comptime n: usize) type{#endsyntax#}</pre>
50685068 <p>
5069 This builtin function takes a function type and returns the type of the parameter at index <code>n</code>.
5069 This builtin function takes a function type and returns the type of the parameter at index {#syntax#}n{#endsyntax#}.
50705070 </p>
50715071 <p>
5072 <code>T</code> must be a function type.
5072 {#syntax#}T{#endsyntax#} must be a function type.
50735073 </p>
50745074 <p>
50755075 Note: This function is deprecated. Use {#link|@typeInfo#} instead.
50765076 </p>
50775077 {#header_close#}
50785078 {#header_open|@atomicLoad#}
5079 <pre><code class="zig">@atomicLoad(comptime T: type, ptr: *const T, comptime ordering: builtin.AtomicOrder) T</code></pre>
5079 <pre>{#syntax#}@atomicLoad(comptime T: type, ptr: *const T, comptime ordering: builtin.AtomicOrder) T{#endsyntax#}</pre>
50805080 <p>
50815081 This builtin function atomically dereferences a pointer and returns the value.
50825082 </p>
50835083 <p>
5084 <code>T</code> must be a pointer type, a <code>bool</code>,
5084 {#syntax#}T{#endsyntax#} must be a pointer type, a {#syntax#}bool{#endsyntax#},
50855085 or an integer whose bit count meets these requirements:
50865086 </p>
50875087 <ul>
......@@ -5095,12 +5095,12 @@ fn seq(c: u8) void {
50955095 </p>
50965096 {#header_close#}
50975097 {#header_open|@atomicRmw#}
5098 <pre><code class="zig">@atomicRmw(comptime T: type, ptr: *T, comptime op: builtin.AtomicRmwOp, operand: T, comptime ordering: builtin.AtomicOrder) T</code></pre>
5098 <pre>{#syntax#}@atomicRmw(comptime T: type, ptr: *T, comptime op: builtin.AtomicRmwOp, operand: T, comptime ordering: builtin.AtomicOrder) T{#endsyntax#}</pre>
50995099 <p>
51005100 This builtin function atomically modifies memory and then returns the previous value.
51015101 </p>
51025102 <p>
5103 <code>T</code> must be a pointer type, a <code>bool</code>,
5103 {#syntax#}T{#endsyntax#} must be a pointer type, a {#syntax#}bool{#endsyntax#},
51045104 or an integer whose bit count meets these requirements:
51055105 </p>
51065106 <ul>
......@@ -5114,29 +5114,29 @@ fn seq(c: u8) void {
51145114 </p>
51155115 {#header_close#}
51165116 {#header_open|@bitCast#}
5117 <pre><code class="zig">@bitCast(comptime DestType: type, value: var) DestType</code></pre>
5117 <pre>{#syntax#}@bitCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre>
51185118 <p>
51195119 Converts a value of one type to another type.
51205120 </p>
51215121 <p>
5122 Asserts that <code>@sizeOf(@typeOf(value)) == @sizeOf(DestType)</code>.
5122 Asserts that {#syntax#}@sizeOf(@typeOf(value)) == @sizeOf(DestType){#endsyntax#}.
51235123 </p>
51245124 <p>
5125 Asserts that <code>@typeId(DestType) != @import("builtin").TypeId.Pointer</code>. Use <code>@ptrCast</code> or <code>@intToPtr</code> if you need this.
5125 Asserts that {#syntax#}@typeId(DestType) != @import("builtin").TypeId.Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@intToPtr{#endsyntax#} if you need this.
51265126 </p>
51275127 <p>
51285128 Can be used for these things for example:
51295129 </p>
51305130 <ul>
5131 <li>Convert <code>f32</code> to <code>u32</code> bits</li>
5132 <li>Convert <code>i32</code> to <code>u32</code> preserving twos complement</li>
5131 <li>Convert {#syntax#}f32{#endsyntax#} to {#syntax#}u32{#endsyntax#} bits</li>
5132 <li>Convert {#syntax#}i32{#endsyntax#} to {#syntax#}u32{#endsyntax#} preserving twos complement</li>
51335133 </ul>
51345134 <p>
5135 Works at compile-time if <code>value</code> is known at compile time. It's a compile error to bitcast a struct to a scalar type of the same size since structs have undefined layout. However if the struct is packed then it works.
5135 Works at compile-time if {#syntax#}value{#endsyntax#} is known at compile time. It's a compile error to bitcast a struct to a scalar type of the same size since structs have undefined layout. However if the struct is packed then it works.
51365136 </p>
51375137 {#header_close#}
51385138 {#header_open|@breakpoint#}
5139 <pre><code class="zig">@breakpoint()</code></pre>
5139 <pre>{#syntax#}@breakpoint(){#endsyntax#}</pre>
51405140 <p>
51415141 This function inserts a platform-specific debug trap instruction which causes
51425142 debuggers to break there.
......@@ -5147,10 +5147,10 @@ fn seq(c: u8) void {
51475147
51485148 {#header_close#}
51495149 {#header_open|@alignCast#}
5150 <pre><code class="zig">@alignCast(comptime alignment: u29, ptr: var) var</code></pre>
5150 <pre>{#syntax#}@alignCast(comptime alignment: u29, ptr: var) var{#endsyntax#}</pre>
51515151 <p>
5152 <code>ptr</code> can be <code>*T</code>, <code>fn()</code>, <code>?*T</code>,
5153 <code>?fn()</code>, or <code>[]T</code>. It returns the same type as <code>ptr</code>
5152 {#syntax#}ptr{#endsyntax#} can be {#syntax#}*T{#endsyntax#}, {#syntax#}fn(){#endsyntax#}, {#syntax#}?*T{#endsyntax#},
5153 {#syntax#}?fn(){#endsyntax#}, or {#syntax#}[]T{#endsyntax#}. It returns the same type as {#syntax#}ptr{#endsyntax#}
51545154 except with the alignment adjusted to the new value.
51555155 </p>
51565156 <p>A {#link|pointer alignment safety check|Incorrect Pointer Alignment#} is added
......@@ -5158,16 +5158,16 @@ fn seq(c: u8) void {
51585158
51595159 {#header_close#}
51605160 {#header_open|@alignOf#}
5161 <pre><code class="zig">@alignOf(comptime T: type) comptime_int</code></pre>
5161 <pre>{#syntax#}@alignOf(comptime T: type) comptime_int{#endsyntax#}</pre>
51625162 <p>
51635163 This function returns the number of bytes that this type should be aligned to
51645164 for the current target to match the C ABI. When the child type of a pointer has
51655165 this alignment, the alignment can be omitted from the type.
51665166 </p>
5167 <pre><code class="zig">const assert = @import("std").debug.assert;
5167 <pre>{#syntax#}const assert = @import("std").debug.assert;
51685168comptime {
51695169 assert(*u32 == *align(@alignOf(u32)) u32);
5170}</code></pre>
5170}{#endsyntax#}</pre>
51715171 <p>
51725172 The result is a target-specific compile time constant. It is guaranteed to be
51735173 less than or equal to {#link|@sizeOf(T)|@sizeOf#}.
......@@ -5176,21 +5176,21 @@ comptime {
51765176 {#header_close#}
51775177
51785178 {#header_open|@boolToInt#}
5179 <pre><code class="zig">@boolToInt(value: bool) u1</code></pre>
5179 <pre>{#syntax#}@boolToInt(value: bool) u1{#endsyntax#}</pre>
51805180 <p>
5181 Converts <code>true</code> to <code>u1(1)</code> and <code>false</code> to
5182 <code>u1(0)</code>.
5181 Converts {#syntax#}true{#endsyntax#} to {#syntax#}u1(1){#endsyntax#} and {#syntax#}false{#endsyntax#} to
5182 {#syntax#}u1(0){#endsyntax#}.
51835183 </p>
51845184 <p>
5185 If the value is known at compile-time, the return type is <code>comptime_int</code>
5186 instead of <code>u1</code>.
5185 If the value is known at compile-time, the return type is {#syntax#}comptime_int{#endsyntax#}
5186 instead of {#syntax#}u1{#endsyntax#}.
51875187 </p>
51885188 {#header_close#}
51895189
51905190 {#header_open|@bytesToSlice#}
5191 <pre><code class="zig">@bytesToSlice(comptime Element: type, bytes: []u8) []Element</code></pre>
5191 <pre>{#syntax#}@bytesToSlice(comptime Element: type, bytes: []u8) []Element{#endsyntax#}</pre>
51925192 <p>
5193 Converts a slice of bytes or array of bytes into a slice of <code>Element</code>.
5193 Converts a slice of bytes or array of bytes into a slice of {#syntax#}Element{#endsyntax#}.
51945194 The resulting slice has the same {#link|pointer|Pointers#} properties as the parameter.
51955195 </p>
51965196 <p>
......@@ -5200,12 +5200,12 @@ comptime {
52005200 {#header_close#}
52015201
52025202 {#header_open|@cDefine#}
5203 <pre><code class="zig">@cDefine(comptime name: []u8, value)</code></pre>
5203 <pre>{#syntax#}@cDefine(comptime name: []u8, value){#endsyntax#}</pre>
52045204 <p>
5205 This function can only occur inside <code>@cImport</code>.
5205 This function can only occur inside {#syntax#}@cImport{#endsyntax#}.
52065206 </p>
52075207 <p>
5208 This appends <code>#define $name $value</code> to the <code>@cImport</code>
5208 This appends <code>#define $name $value</code> to the {#syntax#}@cImport{#endsyntax#}
52095209 temporary buffer.
52105210 </p>
52115211 <p>
......@@ -5215,72 +5215,72 @@ comptime {
52155215 <p>
52165216 Use the void value, like this:
52175217 </p>
5218 <pre><code class="zig">@cDefine("_GNU_SOURCE", {})</code></pre>
5218 <pre>{#syntax#}@cDefine("_GNU_SOURCE", {}){#endsyntax#}</pre>
52195219 {#see_also|Import from C Header File|@cInclude|@cImport|@cUndef|void#}
52205220 {#header_close#}
52215221 {#header_open|@cImport#}
5222 <pre><code class="zig">@cImport(expression) (namespace)</code></pre>
5222 <pre>{#syntax#}@cImport(expression) (namespace){#endsyntax#}</pre>
52235223 <p>
52245224 This function parses C code and imports the functions, types, variables, and
52255225 compatible macro definitions into the result namespace.
52265226 </p>
52275227 <p>
5228 <code>expression</code> is interpreted at compile time. The builtin functions
5229 <code>@cInclude</code>, <code>@cDefine</code>, and <code>@cUndef</code> work
5228 {#syntax#}expression{#endsyntax#} is interpreted at compile time. The builtin functions
5229 {#syntax#}@cInclude{#endsyntax#}, {#syntax#}@cDefine{#endsyntax#}, and {#syntax#}@cUndef{#endsyntax#} work
52305230 within this expression, appending to a temporary buffer which is then parsed as C code.
52315231 </p>
52325232 <p>
5233 Usually you should only have one <code>@cImport</code> in your entire application, because it saves the compiler
5233 Usually you should only have one {#syntax#}@cImport{#endsyntax#} in your entire application, because it saves the compiler
52345234 from invoking clang multiple times, and prevents inline functions from being duplicated.
52355235 </p>
52365236 <p>
5237 Reasons for having multiple <code>@cImport</code> expressions would be:
5237 Reasons for having multiple {#syntax#}@cImport{#endsyntax#} expressions would be:
52385238 </p>
52395239 <ul>
5240 <li>To avoid a symbol collision, for example if foo.h and bar.h both <code>#define CONNECTION_COUNT</code></li>
5240 <li>To avoid a symbol collision, for example if foo.h and bar.h both <code>#define CONNECTION_COUNT</code></li>
52415241 <li>To analyze the C code with different preprocessor defines</li>
52425242 </ul>
52435243 {#see_also|Import from C Header File|@cInclude|@cDefine|@cUndef#}
52445244 {#header_close#}
52455245 {#header_open|@cInclude#}
5246 <pre><code class="zig">@cInclude(comptime path: []u8)</code></pre>
5246 <pre>{#syntax#}@cInclude(comptime path: []u8){#endsyntax#}</pre>
52475247 <p>
5248 This function can only occur inside <code>@cImport</code>.
5248 This function can only occur inside {#syntax#}@cImport{#endsyntax#}.
52495249 </p>
52505250 <p>
5251 This appends <code>#include <$path>\n</code> to the <code>c_import</code>
5251 This appends <code>#include <$path>\n</code> to the {#syntax#}c_import{#endsyntax#}
52525252 temporary buffer.
52535253 </p>
52545254 {#see_also|Import from C Header File|@cImport|@cDefine|@cUndef#}
52555255 {#header_close#}
52565256 {#header_open|@cUndef#}
5257 <pre><code class="zig">@cUndef(comptime name: []u8)</code></pre>
5257 <pre>{#syntax#}@cUndef(comptime name: []u8){#endsyntax#}</pre>
52585258 <p>
5259 This function can only occur inside <code>@cImport</code>.
5259 This function can only occur inside {#syntax#}@cImport{#endsyntax#}.
52605260 </p>
52615261 <p>
5262 This appends <code>#undef $name</code> to the <code>@cImport</code>
5262 This appends <code>#undef $name</code> to the {#syntax#}@cImport{#endsyntax#}
52635263 temporary buffer.
52645264 </p>
52655265 {#see_also|Import from C Header File|@cImport|@cDefine|@cInclude#}
52665266 {#header_close#}
52675267 {#header_open|@clz#}
5268 <pre><code class="zig">@clz(x: T) U</code></pre>
5268 <pre>{#syntax#}@clz(x: T) U{#endsyntax#}</pre>
52695269 <p>
5270 This function counts the number of leading zeroes in <code>x</code> which is an integer
5271 type <code>T</code>.
5270 This function counts the number of leading zeroes in {#syntax#}x{#endsyntax#} which is an integer
5271 type {#syntax#}T{#endsyntax#}.
52725272 </p>
52735273 <p>
5274 The return type <code>U</code> is an unsigned integer with the minimum number
5275 of bits that can represent the value <code>T.bit_count</code>.
5274 The return type {#syntax#}U{#endsyntax#} is an unsigned integer with the minimum number
5275 of bits that can represent the value {#syntax#}T.bit_count{#endsyntax#}.
52765276 </p>
52775277 <p>
5278 If <code>x</code> is zero, <code>@clz</code> returns <code>T.bit_count</code>.
5278 If {#syntax#}x{#endsyntax#} is zero, {#syntax#}@clz{#endsyntax#} returns {#syntax#}T.bit_count{#endsyntax#}.
52795279 </p>
52805280 {#see_also|@ctz|@popCount#}
52815281 {#header_close#}
52825282 {#header_open|@cmpxchgStrong#}
5283 <pre><code class="zig">@cmpxchgStrong(comptime T: type, ptr: *T, expected_value: T, new_value: T, success_order: AtomicOrder, fail_order: AtomicOrder) ?T</code></pre>
5283 <pre>{#syntax#}@cmpxchgStrong(comptime T: type, ptr: *T, expected_value: T, new_value: T, success_order: AtomicOrder, fail_order: AtomicOrder) ?T{#endsyntax#}</pre>
52845284 <p>
52855285 This function performs a strong atomic compare exchange operation. It's the equivalent of this code,
52865286 except atomic:
......@@ -5301,13 +5301,13 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_v
53015301 more efficiently in machine instructions.
53025302 </p>
53035303 <p>
5304 <code>AtomicOrder</code> can be found with <code>@import("builtin").AtomicOrder</code>.
5304 {#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("builtin").AtomicOrder{#endsyntax#}.
53055305 </p>
5306 <p><code>@typeOf(ptr).alignment</code> must be <code>&gt;= @sizeOf(T).</code></p>
5306 <p>{#syntax#}@typeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
53075307 {#see_also|Compile Variables|cmpxchgWeak#}
53085308 {#header_close#}
53095309 {#header_open|@cmpxchgWeak#}
5310 <pre><code class="zig">@cmpxchgWeak(comptime T: type, ptr: *T, expected_value: T, new_value: T, success_order: AtomicOrder, fail_order: AtomicOrder) ?T</code></pre>
5310 <pre>{#syntax#}@cmpxchgWeak(comptime T: type, ptr: *T, expected_value: T, new_value: T, success_order: AtomicOrder, fail_order: AtomicOrder) ?T{#endsyntax#}</pre>
53115311 <p>
53125312 This function performs a weak atomic compare exchange operation. It's the equivalent of this code,
53135313 except atomic:
......@@ -5324,30 +5324,30 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
53245324}
53255325 {#code_end#}
53265326 <p>
5327 If you are using cmpxchg in a loop, the sporadic failure will be no problem, and <code>cmpxchgWeak</code>
5327 If you are using cmpxchg in a loop, the sporadic failure will be no problem, and {#syntax#}cmpxchgWeak{#endsyntax#}
53285328 is the better choice, because it can be implemented more efficiently in machine instructions.
53295329 However if you need a stronger guarantee, use {#link|@cmpxchgStrong#}.
53305330 </p>
53315331 <p>
5332 <code>AtomicOrder</code> can be found with <code>@import("builtin").AtomicOrder</code>.
5332 {#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("builtin").AtomicOrder{#endsyntax#}.
53335333 </p>
5334 <p><code>@typeOf(ptr).alignment</code> must be <code>&gt;= @sizeOf(T).</code></p>
5334 <p>{#syntax#}@typeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
53355335 {#see_also|Compile Variables|cmpxchgStrong#}
53365336 {#header_close#}
53375337 {#header_open|@compileError#}
5338 <pre><code class="zig">@compileError(comptime msg: []u8)</code></pre>
5338 <pre>{#syntax#}@compileError(comptime msg: []u8){#endsyntax#}</pre>
53395339 <p>
53405340 This function, when semantically analyzed, causes a compile error with the
5341 message <code>msg</code>.
5341 message {#syntax#}msg{#endsyntax#}.
53425342 </p>
53435343 <p>
53445344 There are several ways that code avoids being semantically checked, such as
5345 using <code>if</code> or <code>switch</code> with compile time constants,
5346 and <code>comptime</code> functions.
5345 using {#syntax#}if{#endsyntax#} or {#syntax#}switch{#endsyntax#} with compile time constants,
5346 and {#syntax#}comptime{#endsyntax#} functions.
53475347 </p>
53485348 {#header_close#}
53495349 {#header_open|@compileLog#}
5350 <pre><code class="zig">@compileLog(args: ...)</code></pre>
5350 <pre>{#syntax#}@compileLog(args: ...){#endsyntax#}</pre>
53515351 <p>
53525352 This function prints the arguments passed to it at compile-time.
53535353 </p>
......@@ -5382,7 +5382,7 @@ test "main" {
53825382 will ouput:
53835383 </p>
53845384 <p>
5385 If all <code>@compileLog</code> calls are removed or
5385 If all {#syntax#}@compileLog{#endsyntax#} calls are removed or
53865386 not encountered by analysis, the
53875387 program compiles successfully and the generated executable prints:
53885388 </p>
......@@ -5401,88 +5401,88 @@ test "main" {
54015401 {#code_end#}
54025402 {#header_close#}
54035403 {#header_open|@ctz#}
5404 <pre><code class="zig">@ctz(x: T) U</code></pre>
5404 <pre>{#syntax#}@ctz(x: T) U{#endsyntax#}</pre>
54055405 <p>
5406 This function counts the number of trailing zeroes in <code>x</code> which is an integer
5407 type <code>T</code>.
5406 This function counts the number of trailing zeroes in {#syntax#}x{#endsyntax#} which is an integer
5407 type {#syntax#}T{#endsyntax#}.
54085408 </p>
54095409 <p>
5410 The return type <code>U</code> is an unsigned integer with the minimum number
5411 of bits that can represent the value <code>T.bit_count</code>.
5410 The return type {#syntax#}U{#endsyntax#} is an unsigned integer with the minimum number
5411 of bits that can represent the value {#syntax#}T.bit_count{#endsyntax#}.
54125412 </p>
54135413 <p>
5414 If <code>x</code> is zero, <code>@ctz</code> returns <code>T.bit_count</code>.
5414 If {#syntax#}x{#endsyntax#} is zero, {#syntax#}@ctz{#endsyntax#} returns {#syntax#}T.bit_count{#endsyntax#}.
54155415 </p>
54165416 {#see_also|@clz|@popCount#}
54175417 {#header_close#}
54185418 {#header_open|@divExact#}
5419 <pre><code class="zig">@divExact(numerator: T, denominator: T) T</code></pre>
5419 <pre>{#syntax#}@divExact(numerator: T, denominator: T) T{#endsyntax#}</pre>
54205420 <p>
5421 Exact division. Caller guarantees <code>denominator != 0</code> and
5422 <code>@divTrunc(numerator, denominator) * denominator == numerator</code>.
5421 Exact division. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and
5422 {#syntax#}@divTrunc(numerator, denominator) * denominator == numerator{#endsyntax#}.
54235423 </p>
54245424 <ul>
5425 <li><code>@divExact(6, 3) == 2</code></li>
5426 <li><code>@divExact(a, b) * b == a</code></li>
5425 <li>{#syntax#}@divExact(6, 3) == 2{#endsyntax#}</li>
5426 <li>{#syntax#}@divExact(a, b) * b == a{#endsyntax#}</li>
54275427 </ul>
5428 <p>For a function that returns a possible error code, use <code>@import("std").math.divExact</code>.</p>
5428 <p>For a function that returns a possible error code, use {#syntax#}@import("std").math.divExact{#endsyntax#}.</p>
54295429 {#see_also|@divTrunc|@divFloor#}
54305430 {#header_close#}
54315431 {#header_open|@divFloor#}
5432 <pre><code class="zig">@divFloor(numerator: T, denominator: T) T</code></pre>
5432 <pre>{#syntax#}@divFloor(numerator: T, denominator: T) T{#endsyntax#}</pre>
54335433 <p>
54345434 Floored division. Rounds toward negative infinity. For unsigned integers it is
5435 the same as <code>numerator / denominator</code>. Caller guarantees <code>denominator != 0</code> and
5436 <code>!(@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == @minValue(T) and denominator == -1)</code>.
5435 the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and
5436 {#syntax#}!(@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == @minValue(T) and denominator == -1){#endsyntax#}.
54375437 </p>
54385438 <ul>
5439 <li><code>@divFloor(-5, 3) == -2</code></li>
5440 <li><code>@divFloor(a, b) + @mod(a, b) == a</code></li>
5439 <li>{#syntax#}@divFloor(-5, 3) == -2{#endsyntax#}</li>
5440 <li>{#syntax#}@divFloor(a, b) + @mod(a, b) == a{#endsyntax#}</li>
54415441 </ul>
5442 <p>For a function that returns a possible error code, use <code>@import("std").math.divFloor</code>.</p>
5442 <p>For a function that returns a possible error code, use {#syntax#}@import("std").math.divFloor{#endsyntax#}.</p>
54435443 {#see_also|@divTrunc|@divExact#}
54445444 {#header_close#}
54455445 {#header_open|@divTrunc#}
5446 <pre><code class="zig">@divTrunc(numerator: T, denominator: T) T</code></pre>
5446 <pre>{#syntax#}@divTrunc(numerator: T, denominator: T) T{#endsyntax#}</pre>
54475447 <p>
54485448 Truncated division. Rounds toward zero. For unsigned integers it is
5449 the same as <code>numerator / denominator</code>. Caller guarantees <code>denominator != 0</code> and
5450 <code>!(@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == @minValue(T) and denominator == -1)</code>.
5449 the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and
5450 {#syntax#}!(@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == @minValue(T) and denominator == -1){#endsyntax#}.
54515451 </p>
54525452 <ul>
5453 <li><code>@divTrunc(-5, 3) == -1</code></li>
5454 <li><code>@divTrunc(a, b) + @rem(a, b) == a</code></li>
5453 <li>{#syntax#}@divTrunc(-5, 3) == -1{#endsyntax#}</li>
5454 <li>{#syntax#}@divTrunc(a, b) + @rem(a, b) == a{#endsyntax#}</li>
54555455 </ul>
5456 <p>For a function that returns a possible error code, use <code>@import("std").math.divTrunc</code>.</p>
5456 <p>For a function that returns a possible error code, use {#syntax#}@import("std").math.divTrunc{#endsyntax#}.</p>
54575457 {#see_also|@divFloor|@divExact#}
54585458 {#header_close#}
54595459 {#header_open|@embedFile#}
5460 <pre><code class="zig">@embedFile(comptime path: []const u8) [X]u8</code></pre>
5460 <pre>{#syntax#}@embedFile(comptime path: []const u8) [X]u8{#endsyntax#}</pre>
54615461 <p>
54625462 This function returns a compile time constant fixed-size array with length
5463 equal to the byte count of the file given by <code>path</code>. The contents of the array
5463 equal to the byte count of the file given by {#syntax#}path{#endsyntax#}. The contents of the array
54645464 are the contents of the file.
54655465 </p>
54665466 <p>
5467 <code>path</code> is absolute or relative to the current file, just like <code>@import</code>.
5467 {#syntax#}path{#endsyntax#} is absolute or relative to the current file, just like {#syntax#}@import{#endsyntax#}.
54685468 </p>
54695469 {#see_also|@import#}
54705470 {#header_close#}
54715471
54725472 {#header_open|@enumToInt#}
5473 <pre><code class="zig">@enumToInt(enum_value: var) var</code></pre>
5473 <pre>{#syntax#}@enumToInt(enum_value: var) var{#endsyntax#}</pre>
54745474 <p>
54755475 Converts an enumeration value into its integer tag type.
54765476 </p>
54775477 <p>
5478 If the enum has only 1 possible value, the resut is a <code class="zig">comptime_int</code>
5478 If the enum has only 1 possible value, the resut is a {#syntax#}comptime_int{#endsyntax#}
54795479 known at {#link|comptime#}.
54805480 </p>
54815481 {#see_also|@intToEnum#}
54825482 {#header_close#}
54835483
54845484 {#header_open|@errSetCast#}
5485 <pre><code class="zig">@errSetCast(comptime T: DestType, value: var) DestType</code></pre>
5485 <pre>{#syntax#}@errSetCast(comptime T: DestType, value: var) DestType{#endsyntax#}</pre>
54865486 <p>
54875487 Converts an error value from one error set to another error set. Attempting to convert an error
54885488 which is not in the destination error set results in safety-protected {#link|Undefined Behavior#}.
......@@ -5490,24 +5490,24 @@ test "main" {
54905490 {#header_close#}
54915491
54925492 {#header_open|@errorName#}
5493 <pre><code class="zig">@errorName(err: error) []u8</code></pre>
5493 <pre>{#syntax#}@errorName(err: error) []u8{#endsyntax#}</pre>
54945494 <p>
54955495 This function returns the string representation of an error. If an error
54965496 declaration is:
54975497 </p>
5498 <pre><code class="zig">error OutOfMem</code></pre>
5498 <pre>{#syntax#}error OutOfMem{#endsyntax#}</pre>
54995499 <p>
5500 Then the string representation is <code>"OutOfMem"</code>.
5500 Then the string representation is {#syntax#}"OutOfMem"{#endsyntax#}.
55015501 </p>
55025502 <p>
5503 If there are no calls to <code>@errorName</code> in an entire application,
5504 or all calls have a compile-time known value for <code>err</code>, then no
5503 If there are no calls to {#syntax#}@errorName{#endsyntax#} in an entire application,
5504 or all calls have a compile-time known value for {#syntax#}err{#endsyntax#}, then no
55055505 error name table will be generated.
55065506 </p>
55075507 {#header_close#}
55085508
55095509 {#header_open|@errorReturnTrace#}
5510 <pre><code class="zig">@errorReturnTrace() ?*builtin.StackTrace</code></pre>
5510 <pre>{#syntax#}@errorReturnTrace() ?*builtin.StackTrace{#endsyntax#}</pre>
55115511 <p>
55125512 If the binary is built with error return tracing, and this function is invoked in a
55135513 function that calls a function with an error or error union return type, returns a
......@@ -5516,13 +5516,13 @@ test "main" {
55165516 {#header_close#}
55175517
55185518 {#header_open|@errorToInt#}
5519 <pre><code class="zig">@errorToInt(err: var) @IntType(false, @sizeOf(error) * 8)</code></pre>
5519 <pre>{#syntax#}@errorToInt(err: var) @IntType(false, @sizeOf(error) * 8){#endsyntax#}</pre>
55205520 <p>
55215521 Supports the following types:
55225522 </p>
55235523 <ul>
55245524 <li>error unions</li>
5525 <li><code>E!void</code></li>
5525 <li>{#syntax#}E!void{#endsyntax#}</li>
55265526 </ul>
55275527 <p>
55285528 Converts an error to the integer representation of an error.
......@@ -5535,38 +5535,41 @@ test "main" {
55355535 {#header_close#}
55365536
55375537 {#header_open|@export#}
5538 <pre><code class="zig">@export(comptime name: []const u8, target: var, linkage: builtin.GlobalLinkage) []const u8</code></pre>
5538 <pre>{#syntax#}@export(comptime name: []const u8, target: var, linkage: builtin.GlobalLinkage) []const u8{#endsyntax#}</pre>
55395539 <p>
55405540 Creates a symbol in the output object file.
55415541 </p>
55425542 {#header_close#}
55435543
55445544 {#header_open|@fence#}
5545 <pre><code class="zig">@fence(order: AtomicOrder)</code></pre>
5545 <pre>{#syntax#}@fence(order: AtomicOrder){#endsyntax#}</pre>
55465546 <p>
5547 The <code>fence</code> function is used to introduce happens-before edges between operations.
5547 The {#syntax#}fence{#endsyntax#} function is used to introduce happens-before edges between operations.
55485548 </p>
55495549 <p>
5550 <code>AtomicOrder</code> can be found with <code>@import("builtin").AtomicOrder</code>.
5550 {#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("builtin").AtomicOrder{#endsyntax#}.
55515551 </p>
55525552 {#see_also|Compile Variables#}
55535553 {#header_close#}
55545554
55555555 {#header_open|@field#}
5556 <pre><code class="zig">@field(lhs: var, comptime field_name: []const u8) (field)</code></pre>
5557 <p>Preforms field access equivalent to <code>lhs.-&gtfield_name-&lt</code>.</p>
5556 <pre>{#syntax#}@field(lhs: var, comptime field_name: []const u8) (field){#endsyntax#}</pre>
5557 <p>Preforms field access equivalent to {#syntax#}lhs.field_name{#endsyntax#}, except instead
5558 of the field {#syntax#}"field_name"{#endsyntax#}, it accesses the field named by the string
5559 value of {#syntax#}field_name{#endsyntax#}.
5560 </p>
55585561 {#header_close#}
55595562
55605563 {#header_open|@fieldParentPtr#}
5561 <pre><code class="zig">@fieldParentPtr(comptime ParentType: type, comptime field_name: []const u8,
5562 field_ptr: *T) *ParentType</code></pre>
5564 <pre>{#syntax#}@fieldParentPtr(comptime ParentType: type, comptime field_name: []const u8,
5565 field_ptr: *T) *ParentType{#endsyntax#}</pre>
55635566 <p>
55645567 Given a pointer to a field, returns the base pointer of a struct.
55655568 </p>
55665569 {#header_close#}
55675570
55685571 {#header_open|@floatCast#}
5569 <pre><code class="zig">@floatCast(comptime DestType: type, value: var) DestType</code></pre>
5572 <pre>{#syntax#}@floatCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre>
55705573 <p>
55715574 Convert from one float type to another. This cast is safe, but may cause the
55725575 numeric value to lose precision.
......@@ -5574,7 +5577,7 @@ test "main" {
55745577 {#header_close#}
55755578
55765579 {#header_open|@floatToInt#}
5577 <pre><code class="zig">@floatToInt(comptime DestType: type, float: var) DestType</code></pre>
5580 <pre>{#syntax#}@floatToInt(comptime DestType: type, float: var) DestType{#endsyntax#}</pre>
55785581 <p>
55795582 Converts the integer part of a floating point number to the destination type.
55805583 </p>
......@@ -5586,7 +5589,7 @@ test "main" {
55865589 {#header_close#}
55875590
55885591 {#header_open|@frameAddress#}
5589 <pre><code class="zig">@frameAddress()</code></pre>
5592 <pre>{#syntax#}@frameAddress(){#endsyntax#}</pre>
55905593 <p>
55915594 This function returns the base pointer of the current stack frame.
55925595 </p>
......@@ -5600,9 +5603,9 @@ test "main" {
56005603 </p>
56015604 {#header_close#}
56025605 {#header_open|@handle#}
5603 <pre><code class="zig">@handle()</code></pre>
5606 <pre>{#syntax#}@handle(){#endsyntax#}</pre>
56045607 <p>
5605 This function returns a <code>promise->T</code> type, where <code>T</code>
5608 This function returns a {#syntax#}promise->T{#endsyntax#} type, where {#syntax#}T{#endsyntax#}
56065609 is the return type of the async function in scope.
56075610 </p>
56085611 <p>
......@@ -5610,27 +5613,27 @@ test "main" {
56105613 </p>
56115614 {#header_close#}
56125615 {#header_open|@import#}
5613 <pre><code class="zig">@import(comptime path: []u8) (namespace)</code></pre>
5616 <pre>{#syntax#}@import(comptime path: []u8) (namespace){#endsyntax#}</pre>
56145617 <p>
5615 This function finds a zig file corresponding to <code>path</code> and imports all the
5618 This function finds a zig file corresponding to {#syntax#}path{#endsyntax#} and imports all the
56165619 public top level declarations into the resulting namespace.
56175620 </p>
56185621 <p>
5619 <code>path</code> can be a relative or absolute path, or it can be the name of a package.
5620 If it is a relative path, it is relative to the file that contains the <code>@import</code>
5622 {#syntax#}path{#endsyntax#} can be a relative or absolute path, or it can be the name of a package.
5623 If it is a relative path, it is relative to the file that contains the {#syntax#}@import{#endsyntax#}
56215624 function call.
56225625 </p>
56235626 <p>
56245627 The following packages are always available:
56255628 </p>
56265629 <ul>
5627 <li><code>@import("std")</code> - Zig Standard Library</li>
5628 <li><code>@import("builtin")</code> - Compiler-provided types and variables</li>
5630 <li>{#syntax#}@import("std"){#endsyntax#} - Zig Standard Library</li>
5631 <li>{#syntax#}@import("builtin"){#endsyntax#} - Compiler-provided types and variables</li>
56295632 </ul>
56305633 {#see_also|Compile Variables|@embedFile#}
56315634 {#header_close#}
56325635 {#header_open|@inlineCall#}
5633 <pre><code class="zig">@inlineCall(function: X, args: ...) Y</code></pre>
5636 <pre>{#syntax#}@inlineCall(function: X, args: ...) Y{#endsyntax#}</pre>
56345637 <p>
56355638 This calls a function, in the same way that invoking an expression with parentheses does:
56365639 </p>
......@@ -5644,14 +5647,14 @@ test "inline function call" {
56445647fn add(a: i32, b: i32) i32 { return a + b; }
56455648 {#code_end#}
56465649 <p>
5647 Unlike a normal function call, however, <code>@inlineCall</code> guarantees that the call
5650 Unlike a normal function call, however, {#syntax#}@inlineCall{#endsyntax#} guarantees that the call
56485651 will be inlined. If the call cannot be inlined, a compile error is emitted.
56495652 </p>
56505653 {#see_also|@noInlineCall#}
56515654 {#header_close#}
56525655
56535656 {#header_open|@intCast#}
5654 <pre><code class="zig">@intCast(comptime DestType: type, int: var) DestType</code></pre>
5657 <pre>{#syntax#}@intCast(comptime DestType: type, int: var) DestType{#endsyntax#}</pre>
56555658 <p>
56565659 Converts an integer to another integer while keeping the same numerical value.
56575660 Attempting to convert a number which is out of range of the destination type results in
......@@ -5660,7 +5663,7 @@ fn add(a: i32, b: i32) i32 { return a + b; }
56605663 {#header_close#}
56615664
56625665 {#header_open|@intToEnum#}
5663 <pre><code class="zig">@intToEnum(comptime DestType: type, int_value: @TagType(DestType)) DestType</code></pre>
5666 <pre>{#syntax#}@intToEnum(comptime DestType: type, int_value: @TagType(DestType)) DestType{#endsyntax#}</pre>
56645667 <p>
56655668 Converts an integer into an {#link|enum#} value.
56665669 </p>
......@@ -5672,7 +5675,7 @@ fn add(a: i32, b: i32) i32 { return a + b; }
56725675 {#header_close#}
56735676
56745677 {#header_open|@intToError#}
5675 <pre><code class="zig">@intToError(value: @IntType(false, @sizeOf(error) * 8)) error</code></pre>
5678 <pre>{#syntax#}@intToError(value: @IntType(false, @sizeOf(error) * 8)) error{#endsyntax#}</pre>
56765679 <p>
56775680 Converts from the integer representation of an error into the global error set type.
56785681 </p>
......@@ -5688,36 +5691,36 @@ fn add(a: i32, b: i32) i32 { return a + b; }
56885691 {#header_close#}
56895692
56905693 {#header_open|@intToFloat#}
5691 <pre><code class="zig">@intToFloat(comptime DestType: type, int: var) DestType</code></pre>
5694 <pre>{#syntax#}@intToFloat(comptime DestType: type, int: var) DestType{#endsyntax#}</pre>
56925695 <p>
56935696 Converts an integer to the closest floating point representation. To convert the other way, use {#link|@floatToInt#}. This cast is always safe.
56945697 </p>
56955698 {#header_close#}
56965699
56975700 {#header_open|@intToPtr#}
5698 <pre><code class="zig">@intToPtr(comptime DestType: type, int: usize) DestType</code></pre>
5701 <pre>{#syntax#}@intToPtr(comptime DestType: type, int: usize) DestType{#endsyntax#}</pre>
56995702 <p>
57005703 Converts an integer to a pointer. To convert the other way, use {#link|@ptrToInt#}.
57015704 </p>
57025705 {#header_close#}
57035706
57045707 {#header_open|@IntType#}
5705 <pre><code class="zig">@IntType(comptime is_signed: bool, comptime bit_count: u32) type</code></pre>
5708 <pre>{#syntax#}@IntType(comptime is_signed: bool, comptime bit_count: u32) type{#endsyntax#}</pre>
57065709 <p>
57075710 This function returns an integer type with the given signness and bit count.
57085711 </p>
57095712 {#header_close#}
57105713 {#header_open|@maxValue#}
5711 <pre><code class="zig">@maxValue(comptime T: type) comptime_int</code></pre>
5714 <pre>{#syntax#}@maxValue(comptime T: type) comptime_int{#endsyntax#}</pre>
57125715 <p>
5713 This function returns the maximum value of the integer type <code>T</code>.
5716 This function returns the maximum value of the integer type {#syntax#}T{#endsyntax#}.
57145717 </p>
57155718 <p>
57165719 The result is a compile time constant.
57175720 </p>
57185721 {#header_close#}
57195722 {#header_open|@memberCount#}
5720 <pre><code class="zig">@memberCount(comptime T: type) comptime_int</code></pre>
5723 <pre>{#syntax#}@memberCount(comptime T: type) comptime_int{#endsyntax#}</pre>
57215724 <p>
57225725 This function returns the number of members in a struct, enum, or union type.
57235726 </p>
......@@ -5729,7 +5732,7 @@ fn add(a: i32, b: i32) i32 { return a + b; }
57295732 </p>
57305733 {#header_close#}
57315734 {#header_open|@memberName#}
5732 <pre><code class="zig">@memberName(comptime T: type, comptime index: usize) [N]u8</code></pre>
5735 <pre>{#syntax#}@memberName(comptime T: type, comptime index: usize) [N]u8{#endsyntax#}</pre>
57335736 <p>Returns the field name of a struct, union, or enum.</p>
57345737 <p>
57355738 The result is a compile time constant.
......@@ -5739,46 +5742,46 @@ fn add(a: i32, b: i32) i32 { return a + b; }
57395742 </p>
57405743 {#header_close#}
57415744 {#header_open|@memberType#}
5742 <pre><code class="zig">@memberType(comptime T: type, comptime index: usize) type</code></pre>
5745 <pre>{#syntax#}@memberType(comptime T: type, comptime index: usize) type{#endsyntax#}</pre>
57435746 <p>Returns the field type of a struct or union.</p>
57445747 {#header_close#}
57455748 {#header_open|@memcpy#}
5746 <pre><code class="zig">@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize)</code></pre>
5749 <pre>{#syntax#}@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize){#endsyntax#}</pre>
57475750 <p>
5748 This function copies bytes from one region of memory to another. <code>dest</code> and
5749 <code>source</code> are both pointers and must not overlap.
5751 This function copies bytes from one region of memory to another. {#syntax#}dest{#endsyntax#} and
5752 {#syntax#}source{#endsyntax#} are both pointers and must not overlap.
57505753 </p>
57515754 <p>
57525755 This function is a low level intrinsic with no safety mechanisms. Most code
57535756 should not use this function, instead using something like this:
57545757 </p>
5755 <pre><code class="zig">for (source[0...byte_count]) |b, i| dest[i] = b;</code></pre>
5758 <pre>{#syntax#}for (source[0...byte_count]) |b, i| dest[i] = b;{#endsyntax#}</pre>
57565759 <p>
57575760 The optimizer is intelligent enough to turn the above snippet into a memcpy.
57585761 </p>
57595762 <p>There is also a standard library function for this:</p>
5760 <pre><code class="zig">const mem = @import("std").mem;
5761mem.copy(u8, dest[0...byte_count], source[0...byte_count]);</code></pre>
5763 <pre>{#syntax#}const mem = @import("std").mem;
5764mem.copy(u8, dest[0...byte_count], source[0...byte_count]);{#endsyntax#}</pre>
57625765 {#header_close#}
57635766 {#header_open|@memset#}
5764 <pre><code class="zig">@memset(dest: [*]u8, c: u8, byte_count: usize)</code></pre>
5767 <pre>{#syntax#}@memset(dest: [*]u8, c: u8, byte_count: usize){#endsyntax#}</pre>
57655768 <p>
5766 This function sets a region of memory to <code>c</code>. <code>dest</code> is a pointer.
5769 This function sets a region of memory to {#syntax#}c{#endsyntax#}. {#syntax#}dest{#endsyntax#} is a pointer.
57675770 </p>
57685771 <p>
57695772 This function is a low level intrinsic with no safety mechanisms. Most
57705773 code should not use this function, instead using something like this:
57715774 </p>
5772 <pre><code class="zig">for (dest[0...byte_count]) |*b| b.* = c;</code></pre>
5775 <pre>{#syntax#}for (dest[0...byte_count]) |*b| b.* = c;{#endsyntax#}</pre>
57735776 <p>
57745777 The optimizer is intelligent enough to turn the above snippet into a memset.
57755778 </p>
57765779 <p>There is also a standard library function for this:</p>
5777 <pre><code>const mem = @import("std").mem;
5778mem.set(u8, dest, c);</code></pre>
5780 <pre>{#syntax#}const mem = @import("std").mem;
5781mem.set(u8, dest, c);{#endsyntax#}</pre>
57795782 {#header_close#}
57805783 {#header_open|@minValue#}
5781 <pre><code class="zig">@minValue(comptime T: type) comptime_int</code></pre>
5784 <pre>{#syntax#}@minValue(comptime T: type) comptime_int{#endsyntax#}</pre>
57825785 <p>
57835786 This function returns the minimum value of the integer type T.
57845787 </p>
......@@ -5787,31 +5790,31 @@ mem.set(u8, dest, c);</code></pre>
57875790 </p>
57885791 {#header_close#}
57895792 {#header_open|@mod#}
5790 <pre><code class="zig">@mod(numerator: T, denominator: T) T</code></pre>
5793 <pre>{#syntax#}@mod(numerator: T, denominator: T) T{#endsyntax#}</pre>
57915794 <p>
57925795 Modulus division. For unsigned integers this is the same as
5793 <code>numerator % denominator</code>. Caller guarantees <code>denominator &gt; 0</code>.
5796 {#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator &gt; 0{#endsyntax#}.
57945797 </p>
57955798 <ul>
5796 <li><code>@mod(-5, 3) == 1</code></li>
5797 <li><code>@divFloor(a, b) + @mod(a, b) == a</code></li>
5799 <li>{#syntax#}@mod(-5, 3) == 1{#endsyntax#}</li>
5800 <li>{#syntax#}@divFloor(a, b) + @mod(a, b) == a{#endsyntax#}</li>
57985801 </ul>
5799 <p>For a function that returns an error code, see <code>@import("std").math.mod</code>.</p>
5802 <p>For a function that returns an error code, see {#syntax#}@import("std").math.mod{#endsyntax#}.</p>
58005803 {#see_also|@rem#}
58015804 {#header_close#}
58025805 {#header_open|@mulWithOverflow#}
5803 <pre><code class="zig">@mulWithOverflow(comptime T: type, a: T, b: T, result: *T) bool</code></pre>
5806 <pre>{#syntax#}@mulWithOverflow(comptime T: type, a: T, b: T, result: *T) bool{#endsyntax#}</pre>
58045807 <p>
5805 Performs <code>result.* = a * b</code>. If overflow or underflow occurs,
5806 stores the overflowed bits in <code>result</code> and returns <code>true</code>.
5807 If no overflow or underflow occurs, returns <code>false</code>.
5808 Performs {#syntax#}result.* = a * b{#endsyntax#}. If overflow or underflow occurs,
5809 stores the overflowed bits in {#syntax#}result{#endsyntax#} and returns {#syntax#}true{#endsyntax#}.
5810 If no overflow or underflow occurs, returns {#syntax#}false{#endsyntax#}.
58085811 </p>
58095812 {#header_close#}
58105813 {#header_open|@newStackCall#}
5811 <pre><code class="zig">@newStackCall(new_stack: []u8, function: var, args: ...) var</code></pre>
5814 <pre>{#syntax#}@newStackCall(new_stack: []u8, function: var, args: ...) var{#endsyntax#}</pre>
58125815 <p>
58135816 This calls a function, in the same way that invoking an expression with parentheses does. However,
5814 instead of using the same stack as the caller, the function uses the stack provided in the <code>new_stack</code>
5817 instead of using the same stack as the caller, the function uses the stack provided in the {#syntax#}new_stack{#endsyntax#}
58155818 parameter.
58165819 </p>
58175820 {#code_begin|test#}
......@@ -5844,7 +5847,7 @@ fn targetFunction(x: i32) usize {
58445847 {#code_end#}
58455848 {#header_close#}
58465849 {#header_open|@noInlineCall#}
5847 <pre><code class="zig">@noInlineCall(function: var, args: ...) var</code></pre>
5850 <pre>{#syntax#}@noInlineCall(function: var, args: ...) var{#endsyntax#}</pre>
58485851 <p>
58495852 This calls a function, in the same way that invoking an expression with parentheses does:
58505853 </p>
......@@ -5860,19 +5863,19 @@ fn add(a: i32, b: i32) i32 {
58605863}
58615864 {#code_end#}
58625865 <p>
5863 Unlike a normal function call, however, <code>@noInlineCall</code> guarantees that the call
5866 Unlike a normal function call, however, {#syntax#}@noInlineCall{#endsyntax#} guarantees that the call
58645867 will not be inlined. If the call must be inlined, a compile error is emitted.
58655868 </p>
58665869 {#see_also|@inlineCall#}
58675870 {#header_close#}
58685871 {#header_open|@offsetOf#}
5869 <pre><code class="zig">@offsetOf(comptime T: type, comptime field_name: [] const u8) comptime_int</code></pre>
5872 <pre>{#syntax#}@offsetOf(comptime T: type, comptime field_name: [] const u8) comptime_int{#endsyntax#}</pre>
58705873 <p>
58715874 This function returns the byte offset of a field relative to its containing struct.
58725875 </p>
58735876 {#header_close#}
58745877 {#header_open|@OpaqueType#}
5875 <pre><code class="zig">@OpaqueType() type</code></pre>
5878 <pre>{#syntax#}@OpaqueType() type{#endsyntax#}</pre>
58765879 <p>
58775880 Creates a new type with an unknown size and alignment.
58785881 </p>
......@@ -5895,14 +5898,14 @@ test "call foo" {
58955898 {#code_end#}
58965899 {#header_close#}
58975900 {#header_open|@panic#}
5898 <pre><code class="zig">@panic(message: []const u8) noreturn</code></pre>
5901 <pre>{#syntax#}@panic(message: []const u8) noreturn{#endsyntax#}</pre>
58995902 <p>
59005903 Invokes the panic handler function. By default the panic handler function
5901 calls the public <code>panic</code> function exposed in the root source file, or
5902 if there is not one specified, invokes the one provided in <code>std/special/panic.zig</code>.
5904 calls the public {#syntax#}panic{#endsyntax#} function exposed in the root source file, or
5905 if there is not one specified, invokes the one provided in {#syntax#}std/special/panic.zig{#endsyntax#}.
59035906 </p>
5904 <p>Generally it is better to use <code>@import("std").debug.panic</code>.
5905 However, <code>@panic</code> can be useful for 2 scenarios:
5907 <p>Generally it is better to use {#syntax#}@import("std").debug.panic{#endsyntax#}.
5908 However, {#syntax#}@panic{#endsyntax#} can be useful for 2 scenarios:
59065909 </p>
59075910 <ul>
59085911 <li>From library code, calling the programmer's panic function if they exposed one in the root source file.</li>
......@@ -5911,50 +5914,50 @@ test "call foo" {
59115914 {#see_also|Root Source File#}
59125915 {#header_close#}
59135916 {#header_open|@popCount#}
5914 <pre><code class="zig">@popCount(integer: var) var</code></pre>
5917 <pre>{#syntax#}@popCount(integer: var) var{#endsyntax#}</pre>
59155918 <p>Counts the number of bits set in an integer.</p>
59165919 <p>
5917 If <code>integer</code> is known at {#link|comptime#}, the return type is <code>comptime_int</code>.
5920 If {#syntax#}integer{#endsyntax#} is known at {#link|comptime#}, the return type is {#syntax#}comptime_int{#endsyntax#}.
59185921 Otherwise, the return type is an unsigned integer with the minimum number
59195922 of bits that can represent the bit count of the integer type.
59205923 </p>
59215924 {#see_also|@ctz|@clz#}
59225925 {#header_close#}
59235926 {#header_open|@ptrCast#}
5924 <pre><code class="zig">@ptrCast(comptime DestType: type, value: var) DestType</code></pre>
5927 <pre>{#syntax#}@ptrCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre>
59255928 <p>
59265929 Converts a pointer of one type to a pointer of another type.
59275930 </p>
59285931 {#header_close#}
59295932 {#header_open|@ptrToInt#}
5930 <pre><code class="zig">@ptrToInt(value: var) usize</code></pre>
5933 <pre>{#syntax#}@ptrToInt(value: var) usize{#endsyntax#}</pre>
59315934 <p>
5932 Converts <code>value</code> to a <code>usize</code> which is the address of the pointer. <code>value</code> can be one of these types:
5935 Converts {#syntax#}value{#endsyntax#} to a {#syntax#}usize{#endsyntax#} which is the address of the pointer. {#syntax#}value{#endsyntax#} can be one of these types:
59335936 </p>
59345937 <ul>
5935 <li><code>*T</code></li>
5936 <li><code>?*T</code></li>
5937 <li><code>fn()</code></li>
5938 <li><code>?fn()</code></li>
5938 <li>{#syntax#}*T{#endsyntax#}</li>
5939 <li>{#syntax#}?*T{#endsyntax#}</li>
5940 <li>{#syntax#}fn(){#endsyntax#}</li>
5941 <li>{#syntax#}?fn(){#endsyntax#}</li>
59395942 </ul>
59405943 <p>To convert the other way, use {#link|@intToPtr#}</p>
59415944
59425945 {#header_close#}
59435946 {#header_open|@rem#}
5944 <pre><code class="zig">@rem(numerator: T, denominator: T) T</code></pre>
5947 <pre>{#syntax#}@rem(numerator: T, denominator: T) T{#endsyntax#}</pre>
59455948 <p>
59465949 Remainder division. For unsigned integers this is the same as
5947 <code>numerator % denominator</code>. Caller guarantees <code>denominator &gt; 0</code>.
5950 {#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator > 0{#endsyntax#}.
59485951 </p>
59495952 <ul>
5950 <li><code>@rem(-5, 3) == -2</code></li>
5951 <li><code>@divTrunc(a, b) + @rem(a, b) == a</code></li>
5953 <li>{#syntax#}@rem(-5, 3) == -2{#endsyntax#}</li>
5954 <li>{#syntax#}@divTrunc(a, b) + @rem(a, b) == a{#endsyntax#}</li>
59525955 </ul>
5953 <p>For a function that returns an error code, see <code>@import("std").math.rem</code>.</p>
5956 <p>For a function that returns an error code, see {#syntax#}@import("std").math.rem{#endsyntax#}.</p>
59545957 {#see_also|@mod#}
59555958 {#header_close#}
59565959 {#header_open|@returnAddress#}
5957 <pre><code class="zig">@returnAddress()</code></pre>
5960 <pre>{#syntax#}@returnAddress(){#endsyntax#}</pre>
59585961 <p>
59595962 This function returns a pointer to the return address of the current stack
59605963 frame.
......@@ -5968,32 +5971,32 @@ test "call foo" {
59685971 </p>
59695972 {#header_close#}
59705973 {#header_open|@setAlignStack#}
5971 <pre><code class="zig">@setAlignStack(comptime alignment: u29)</code></pre>
5974 <pre>{#syntax#}@setAlignStack(comptime alignment: u29){#endsyntax#}</pre>
59725975 <p>
5973 Ensures that a function will have a stack alignment of at least <code>alignment</code> bytes.
5976 Ensures that a function will have a stack alignment of at least {#syntax#}alignment{#endsyntax#} bytes.
59745977 </p>
59755978 {#header_close#}
59765979 {#header_open|@setCold#}
5977 <pre><code class="zig">@setCold(is_cold: bool)</code></pre>
5980 <pre>{#syntax#}@setCold(is_cold: bool){#endsyntax#}</pre>
59785981 <p>
59795982 Tells the optimizer that a function is rarely called.
59805983 </p>
59815984 {#header_close#}
59825985 {#header_open|@setRuntimeSafety#}
5983 <pre><code class="zig">@setRuntimeSafety(safety_on: bool)</code></pre>
5986 <pre>{#syntax#}@setRuntimeSafety(safety_on: bool){#endsyntax#}</pre>
59845987 <p>
59855988 Sets whether runtime safety checks are on for the scope that contains the function call.
59865989 </p>
59875990
59885991 {#header_close#}
59895992 {#header_open|@setEvalBranchQuota#}
5990 <pre><code class="zig">@setEvalBranchQuota(new_quota: usize)</code></pre>
5993 <pre>{#syntax#}@setEvalBranchQuota(new_quota: usize){#endsyntax#}</pre>
59915994 <p>
59925995 Changes the maximum number of backwards branches that compile-time code
59935996 execution can use before giving up and making a compile error.
59945997 </p>
59955998 <p>
5996 If the <code>new_quota</code> is smaller than the default quota (<code>1000</code>) or
5999 If the {#syntax#}new_quota{#endsyntax#} is smaller than the default quota ({#syntax#}1000{#endsyntax#}) or
59976000 a previously explicitly set quota, it is ignored.
59986001 </p>
59996002 <p>
......@@ -6007,7 +6010,7 @@ test "foo" {
60076010 }
60086011}
60096012 {#code_end#}
6010 <p>Now we use <code class="zig">@setEvalBranchQuota</code>:</p>
6013 <p>Now we use {#syntax#}@setEvalBranchQuota{#endsyntax#}:</p>
60116014 {#code_begin|test#}
60126015test "foo" {
60136016 comptime {
......@@ -6021,7 +6024,7 @@ test "foo" {
60216024 {#see_also|comptime#}
60226025 {#header_close#}
60236026 {#header_open|@setFloatMode#}
6024 <pre><code class="zig">@setFloatMode(mode: @import("builtin").FloatMode)</code></pre>
6027 <pre>{#syntax#}@setFloatMode(mode: @import("builtin").FloatMode){#endsyntax#}</pre>
60256028 <p>
60266029 Sets the floating point mode of the current scope. Possible values are:
60276030 </p>
......@@ -6033,10 +6036,10 @@ pub const FloatMode = enum {
60336036 {#code_end#}
60346037 <ul>
60356038 <li>
6036 <code>Strict</code> (default) - Floating point operations follow strict IEEE compliance.
6039 {#syntax#}Strict{#endsyntax#} (default) - Floating point operations follow strict IEEE compliance.
60376040 </li>
60386041 <li>
6039 <code>Optimized</code> - Floating point operations may do all of the following:
6042 {#syntax#}Optimized{#endsyntax#} - Floating point operations may do all of the following:
60406043 <ul>
60416044 <li>Assume the arguments and result are not NaN. Optimizations are required to retain defined behavior over NaNs, but the value of the result is undefined.</li>
60426045 <li>Assume the arguments and result are not +/-Inf. Optimizations are required to retain defined behavior over +/-Inf, but the value of the result is undefined.</li>
......@@ -6055,54 +6058,54 @@ pub const FloatMode = enum {
60556058 {#see_also|Floating Point Operations#}
60566059 {#header_close#}
60576060 {#header_open|@setGlobalLinkage#}
6058 <pre><code class="zig">@setGlobalLinkage(global_variable_name, comptime linkage: GlobalLinkage)</code></pre>
6061 <pre>{#syntax#}@setGlobalLinkage(global_variable_name, comptime linkage: GlobalLinkage){#endsyntax#}</pre>
60596062 <p>
6060 <code>GlobalLinkage</code> can be found with <code>@import("builtin").GlobalLinkage</code>.
6063 {#syntax#}GlobalLinkage{#endsyntax#} can be found with {#syntax#}@import("builtin").GlobalLinkage{#endsyntax#}.
60616064 </p>
60626065 {#see_also|Compile Variables#}
60636066 {#header_close#}
60646067 {#header_open|@shlExact#}
6065 <pre><code class="zig">@shlExact(value: T, shift_amt: Log2T) T</code></pre>
6068 <pre>{#syntax#}@shlExact(value: T, shift_amt: Log2T) T{#endsyntax#}</pre>
60666069 <p>
6067 Performs the left shift operation (<code>&lt;&lt;</code>). Caller guarantees
6070 Performs the left shift operation ({#syntax#}<<{#endsyntax#}). Caller guarantees
60686071 that the shift will not shift any 1 bits out.
60696072 </p>
60706073 <p>
6071 The type of <code>shift_amt</code> is an unsigned integer with <code>log2(T.bit_count)</code> bits.
6072 This is because <code>shift_amt &gt;= T.bit_count</code> is undefined behavior.
6074 The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(T.bit_count){#endsyntax#} bits.
6075 This is because {#syntax#}shift_amt >= T.bit_count{#endsyntax#} is undefined behavior.
60736076 </p>
60746077 {#see_also|@shrExact|@shlWithOverflow#}
60756078 {#header_close#}
60766079 {#header_open|@shlWithOverflow#}
6077 <pre><code class="zig">@shlWithOverflow(comptime T: type, a: T, shift_amt: Log2T, result: *T) bool</code></pre>
6080 <pre>{#syntax#}@shlWithOverflow(comptime T: type, a: T, shift_amt: Log2T, result: *T) bool{#endsyntax#}</pre>
60786081 <p>
6079 Performs <code>result.* = a &lt;&lt; b</code>. If overflow or underflow occurs,
6080 stores the overflowed bits in <code>result</code> and returns <code>true</code>.
6081 If no overflow or underflow occurs, returns <code>false</code>.
6082 Performs {#syntax#}result.* = a << b{#endsyntax#}. If overflow or underflow occurs,
6083 stores the overflowed bits in {#syntax#}result{#endsyntax#} and returns {#syntax#}true{#endsyntax#}.
6084 If no overflow or underflow occurs, returns {#syntax#}false{#endsyntax#}.
60826085 </p>
60836086 <p>
6084 The type of <code>shift_amt</code> is an unsigned integer with <code>log2(T.bit_count)</code> bits.
6085 This is because <code>shift_amt &gt;= T.bit_count</code> is undefined behavior.
6087 The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(T.bit_count){#endsyntax#} bits.
6088 This is because {#syntax#}shift_amt >= T.bit_count{#endsyntax#} is undefined behavior.
60866089 </p>
60876090 {#see_also|@shlExact|@shrExact#}
60886091 {#header_close#}
60896092 {#header_open|@shrExact#}
6090 <pre><code class="zig">@shrExact(value: T, shift_amt: Log2T) T</code></pre>
6093 <pre>{#syntax#}@shrExact(value: T, shift_amt: Log2T) T{#endsyntax#}</pre>
60916094 <p>
6092 Performs the right shift operation (<code>&gt;&gt;</code>). Caller guarantees
6095 Performs the right shift operation ({#syntax#}>>{#endsyntax#}). Caller guarantees
60936096 that the shift will not shift any 1 bits out.
60946097 </p>
60956098 <p>
6096 The type of <code>shift_amt</code> is an unsigned integer with <code>log2(T.bit_count)</code> bits.
6097 This is because <code>shift_amt &gt;= T.bit_count</code> is undefined behavior.
6099 The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(T.bit_count){#endsyntax#} bits.
6100 This is because {#syntax#}shift_amt >= T.bit_count{#endsyntax#} is undefined behavior.
60986101 </p>
60996102 {#see_also|@shlExact|@shlWithOverflow#}
61006103 {#header_close#}
61016104
61026105 {#header_open|@sizeOf#}
6103 <pre><code class="zig">@sizeOf(comptime T: type) comptime_int</code></pre>
6106 <pre>{#syntax#}@sizeOf(comptime T: type) comptime_int{#endsyntax#}</pre>
61046107 <p>
6105 This function returns the number of bytes it takes to store <code>T</code> in memory.
6108 This function returns the number of bytes it takes to store {#syntax#}T{#endsyntax#} in memory.
61066109 </p>
61076110 <p>
61086111 The result is a target-specific compile time constant.
......@@ -6110,39 +6113,39 @@ pub const FloatMode = enum {
61106113 {#header_close#}
61116114
61126115 {#header_open|@sliceToBytes#}
6113 <pre><code class="zig">@sliceToBytes(value: var) []u8</code></pre>
6116 <pre>{#syntax#}@sliceToBytes(value: var) []u8{#endsyntax#}</pre>
61146117 <p>
6115 Converts a slice or array to a slice of <code>u8</code>. The resulting slice has the same
6118 Converts a slice or array to a slice of {#syntax#}u8{#endsyntax#}. The resulting slice has the same
61166119 {#link|pointer|Pointers#} properties as the parameter.
61176120 </p>
61186121 {#header_close#}
61196122
61206123 {#header_open|@sqrt#}
6121 <pre><code class="zig">@sqrt(comptime T: type, value: T) T</code></pre>
6124 <pre>{#syntax#}@sqrt(comptime T: type, value: T) T{#endsyntax#}</pre>
61226125 <p>
61236126 Performs the square root of a floating point number. Uses a dedicated hardware instruction
61246127 when available. Currently only supports f32 and f64 at runtime. f128 at runtime is TODO.
61256128 </p>
61266129 <p>
6127 This is a low-level intrinsic. Most code can use <code>std.math.sqrt</code> instead.
6130 This is a low-level intrinsic. Most code can use {#syntax#}std.math.sqrt{#endsyntax#} instead.
61286131 </p>
61296132 {#header_close#}
61306133 {#header_open|@subWithOverflow#}
6131 <pre><code class="zig">@subWithOverflow(comptime T: type, a: T, b: T, result: *T) bool</code></pre>
6134 <pre>{#syntax#}@subWithOverflow(comptime T: type, a: T, b: T, result: *T) bool{#endsyntax#}</pre>
61326135 <p>
6133 Performs <code>result.* = a - b</code>. If overflow or underflow occurs,
6134 stores the overflowed bits in <code>result</code> and returns <code>true</code>.
6135 If no overflow or underflow occurs, returns <code>false</code>.
6136 Performs {#syntax#}result.* = a - b{#endsyntax#}. If overflow or underflow occurs,
6137 stores the overflowed bits in {#syntax#}result{#endsyntax#} and returns {#syntax#}true{#endsyntax#}.
6138 If no overflow or underflow occurs, returns {#syntax#}false{#endsyntax#}.
61366139 </p>
61376140 {#header_close#}
61386141 {#header_open|@tagName#}
6139 <pre><code class="zig">@tagName(value: var) []const u8</code></pre>
6142 <pre>{#syntax#}@tagName(value: var) []const u8{#endsyntax#}</pre>
61406143 <p>
61416144 Converts an enum value or union value to a slice of bytes representing the name.
61426145 </p>
61436146 {#header_close#}
61446147 {#header_open|@TagType#}
6145 <pre><code class="zig">@TagType(T: type) type</code></pre>
6148 <pre>{#syntax#}@TagType(T: type) type{#endsyntax#}</pre>
61466149 <p>
61476150 For an enum, returns the integer type that is used to store the enumeration value.
61486151 </p>
......@@ -6151,7 +6154,7 @@ pub const FloatMode = enum {
61516154 </p>
61526155 {#header_close#}
61536156 {#header_open|@truncate#}
6154 <pre><code class="zig">@truncate(comptime T: type, integer) T</code></pre>
6157 <pre>{#syntax#}@truncate(comptime T: type, integer) T{#endsyntax#}</pre>
61556158 <p>
61566159 This function truncates bits from an integer type, resulting in a smaller
61576160 integer type.
......@@ -6160,14 +6163,14 @@ pub const FloatMode = enum {
61606163 The following produces a crash in debug mode and undefined behavior in
61616164 release mode:
61626165 </p>
6163 <pre><code class="zig">const a: u16 = 0xabcd;
6164const b: u8 = u8(a);</code></pre>
6166 <pre>{#syntax#}const a: u16 = 0xabcd;
6167const b: u8 = u8(a);{#endsyntax#}</pre>
61656168 <p>
61666169 However this is well defined and working code:
61676170 </p>
6168 <pre><code class="zig">const a: u16 = 0xabcd;
6171 <pre>{#syntax#}const a: u16 = 0xabcd;
61696172const b: u8 = @truncate(u8, a);
6170// b is now 0xcd</code></pre>
6173// b is now 0xcd{#endsyntax#}</pre>
61716174 <p>
61726175 This function always truncates the significant bits of the integer, regardless
61736176 of endianness on the target platform.
......@@ -6175,7 +6178,7 @@ const b: u8 = @truncate(u8, a);
61756178
61766179 {#header_close#}
61776180 {#header_open|@typeId#}
6178 <pre><code class="zig">@typeId(comptime T: type) @import("builtin").TypeId</code></pre>
6181 <pre>{#syntax#}@typeId(comptime T: type) @import("builtin").TypeId{#endsyntax#}</pre>
61796182 <p>
61806183 Returns which kind of type something is. Possible values:
61816184 </p>
......@@ -6209,7 +6212,7 @@ pub const TypeId = enum {
62096212 {#code_end#}
62106213 {#header_close#}
62116214 {#header_open|@typeInfo#}
6212 <pre><code class="zig">@typeInfo(comptime T: type) @import("builtin").TypeInfo</code></pre>
6215 <pre>{#syntax#}@typeInfo(comptime T: type) @import("builtin").TypeInfo{#endsyntax#}</pre>
62136216 <p>
62146217 Returns information on the type. Returns a value of the following union:
62156218 </p>
......@@ -6392,14 +6395,14 @@ pub const TypeInfo = union(TypeId) {
63926395 {#code_end#}
63936396 {#header_close#}
63946397 {#header_open|@typeName#}
6395 <pre><code class="zig">@typeName(T: type) []u8</code></pre>
6398 <pre>{#syntax#}@typeName(T: type) []u8{#endsyntax#}</pre>
63966399 <p>
63976400 This function returns the string representation of a type.
63986401 </p>
63996402
64006403 {#header_close#}
64016404 {#header_open|@typeOf#}
6402 <pre><code class="zig">@typeOf(expression) type</code></pre>
6405 <pre>{#syntax#}@typeOf(expression) type{#endsyntax#}</pre>
64036406 <p>
64046407 This function returns a compile-time constant, which is the type of the
64056408 expression passed as an argument. The expression is evaluated.
......@@ -6576,11 +6579,11 @@ pub fn main() void {
65766579 {#header_open|Default Operations#}
65776580 <p>The following operators can cause integer overflow:</p>
65786581 <ul>
6579 <li><code>+</code> (addition)</li>
6580 <li><code>-</code> (subtraction)</li>
6581 <li><code>-</code> (negation)</li>
6582 <li><code>*</code> (multiplication)</li>
6583 <li><code>/</code> (division)</li>
6582 <li>{#syntax#}+{#endsyntax#} (addition)</li>
6583 <li>{#syntax#}-{#endsyntax#} (subtraction)</li>
6584 <li>{#syntax#}-{#endsyntax#} (negation)</li>
6585 <li>{#syntax#}*{#endsyntax#} (multiplication)</li>
6586 <li>{#syntax#}/{#endsyntax#} (division)</li>
65846587 <li>{#link|@divTrunc#} (division)</li>
65856588 <li>{#link|@divFloor#} (division)</li>
65866589 <li>{#link|@divExact#} (division)</li>
......@@ -6606,13 +6609,13 @@ pub fn main() void {
66066609 {#header_open|Standard Library Math Functions#}
66076610 <p>These functions provided by the standard library return possible errors.</p>
66086611 <ul>
6609 <li><code>@import("std").math.add</code></li>
6610 <li><code>@import("std").math.sub</code></li>
6611 <li><code>@import("std").math.mul</code></li>
6612 <li><code>@import("std").math.divTrunc</code></li>
6613 <li><code>@import("std").math.divFloor</code></li>
6614 <li><code>@import("std").math.divExact</code></li>
6615 <li><code>@import("std").math.shl</code></li>
6612 <li>{#syntax#}@import("std").math.add{#endsyntax#}</li>
6613 <li>{#syntax#}@import("std").math.sub{#endsyntax#}</li>
6614 <li>{#syntax#}@import("std").math.mul{#endsyntax#}</li>
6615 <li>{#syntax#}@import("std").math.divTrunc{#endsyntax#}</li>
6616 <li>{#syntax#}@import("std").math.divFloor{#endsyntax#}</li>
6617 <li>{#syntax#}@import("std").math.divExact{#endsyntax#}</li>
6618 <li>{#syntax#}@import("std").math.shl{#endsyntax#}</li>
66166619 </ul>
66176620 <p>Example of catching an overflow for addition:</p>
66186621 {#code_begin|exe_err#}
......@@ -6632,7 +6635,7 @@ pub fn main() !void {
66326635 {#header_close#}
66336636 {#header_open|Builtin Overflow Functions#}
66346637 <p>
6635 These builtins return a <code>bool</code> of whether or not overflow
6638 These builtins return a {#syntax#}bool{#endsyntax#} of whether or not overflow
66366639 occurred, as well as returning the overflowed bits:
66376640 </p>
66386641 <ul>
......@@ -6663,10 +6666,10 @@ pub fn main() void {
66636666 These operations have guaranteed wraparound semantics.
66646667 </p>
66656668 <ul>
6666 <li><code>+%</code> (wraparound addition)</li>
6667 <li><code>-%</code> (wraparound subtraction)</li>
6668 <li><code>-%</code> (wraparound negation)</li>
6669 <li><code>*%</code> (wraparound multiplication)</li>
6669 <li>{#syntax#}+%{#endsyntax#} (wraparound addition)</li>
6670 <li>{#syntax#}-%{#endsyntax#} (wraparound subtraction)</li>
6671 <li>{#syntax#}-%{#endsyntax#} (wraparound negation)</li>
6672 <li>{#syntax#}*%{#endsyntax#} (wraparound multiplication)</li>
66706673 </ul>
66716674 {#code_begin|test#}
66726675const assert = @import("std").debug.assert;
......@@ -6818,7 +6821,7 @@ pub fn main() void {
68186821}
68196822 {#code_end#}
68206823 <p>One way to avoid this crash is to test for null instead of assuming non-null, with
6821 the <code>if</code> expression:</p>
6824 the {#syntax#}if{#endsyntax#} expression:</p>
68226825 {#code_begin|exe|test#}
68236826const warn = @import("std").debug.warn;
68246827pub fn main() void {
......@@ -6858,7 +6861,7 @@ fn getNumberOrFail() !i32 {
68586861}
68596862 {#code_end#}
68606863 <p>One way to avoid this crash is to test for an error instead of assuming a successful result, with
6861 the <code>if</code> expression:</p>
6864 the {#syntax#}if{#endsyntax#} expression:</p>
68626865 {#code_begin|exe#}
68636866const warn = @import("std").debug.warn;
68646867
......@@ -7022,7 +7025,7 @@ fn bar(f: *Foo) void {
70227025}
70237026 {#code_end#}
70247027 <p>
7025 This safety is not available for <code>extern</code> or <code>packed</code> unions.
7028 This safety is not available for {#syntax#}extern{#endsyntax#} or {#syntax#}packed{#endsyntax#} unions.
70267029 </p>
70277030 <p>
70287031 To change the active field of a union, assign the entire union, like this:
......@@ -7087,7 +7090,7 @@ fn bar(f: *Foo) void {
70877090 {#header_close#}
70887091 {#header_open|Compile Variables#}
70897092 <p>
7090 Compile variables are accessible by importing the <code>"builtin"</code> package,
7093 Compile variables are accessible by importing the {#syntax#}"builtin"{#endsyntax#} package,
70917094 which the compiler makes available to every Zig source file. It contains
70927095 compile-time constants such as the current target, endianness, and release mode.
70937096 </p>
......@@ -7096,7 +7099,7 @@ const builtin = @import("builtin");
70967099const separator = if (builtin.os == builtin.Os.windows) '\\' else '/';
70977100 {#code_end#}
70987101 <p>
7099 Example of what is imported with <code>@import("builtin")</code>:
7102 Example of what is imported with {#syntax#}@import("builtin"){#endsyntax#}:
71007103 </p>
71017104 {#builtin#}
71027105 {#see_also|Build Mode#}
......@@ -7135,16 +7138,16 @@ const separator = if (builtin.os == builtin.Os.windows) '\\' else '/';
71357138 These have guaranteed C ABI compatibility and can be used like any other type.
71367139 </p>
71377140 <ul>
7138 <li><code>c_short</code></li>
7139 <li><code>c_ushort</code></li>
7140 <li><code>c_int</code></li>
7141 <li><code>c_uint</code></li>
7142 <li><code>c_long</code></li>
7143 <li><code>c_ulong</code></li>
7144 <li><code>c_longlong</code></li>
7145 <li><code>c_ulonglong</code></li>
7146 <li><code>c_longdouble</code></li>
7147 <li><code>c_void</code></li>
7141 <li>{#syntax#}c_short{#endsyntax#}</li>
7142 <li>{#syntax#}c_ushort{#endsyntax#}</li>
7143 <li>{#syntax#}c_int{#endsyntax#}</li>
7144 <li>{#syntax#}c_uint{#endsyntax#}</li>
7145 <li>{#syntax#}c_long{#endsyntax#}</li>
7146 <li>{#syntax#}c_ulong{#endsyntax#}</li>
7147 <li>{#syntax#}c_longlong{#endsyntax#}</li>
7148 <li>{#syntax#}c_ulonglong{#endsyntax#}</li>
7149 <li>{#syntax#}c_longdouble{#endsyntax#}</li>
7150 <li>{#syntax#}c_void{#endsyntax#}</li>
71487151 </ul>
71497152 {#see_also|Primitive Types#}
71507153 {#header_close#}
......@@ -7166,7 +7169,7 @@ pub fn main() void {
71667169 {#header_close#}
71677170 {#header_open|Import from C Header File#}
71687171 <p>
7169 The <code>@cImport</code> builtin function can be used
7172 The {#syntax#}@cImport{#endsyntax#} builtin function can be used
71707173 to directly import symbols from .h files:
71717174 </p>
71727175 {#code_begin|exe#}
......@@ -7181,7 +7184,7 @@ pub fn main() void {
71817184}
71827185 {#code_end#}
71837186 <p>
7184 The <code>@cImport</code> function takes an expression as a parameter.
7187 The {#syntax#}@cImport{#endsyntax#} function takes an expression as a parameter.
71857188 This expression is evaluated at compile-time and is used to control
71867189 preprocessor directives and include multiple .h files:
71877190 </p>
......@@ -7205,7 +7208,7 @@ const c = @cImport({
72057208 {#header_open|Exporting a C Library#}
72067209 <p>
72077210 One of the primary use cases for Zig is exporting a library with the C ABI for other programming languages
7208 to call into. The <code>export</code> keyword in front of functions, variables, and types causes them to
7211 to call into. The {#syntax#}export{#endsyntax#} keyword in front of functions, variables, and types causes them to
72097212 be part of the library API:
72107213 </p>
72117214 <p class="file">mathtest.zig</p>
......@@ -7454,7 +7457,7 @@ Environments:
74547457 coreclr
74557458 opencl</code></pre>
74567459 <p>
7457 The Zig Standard Library (<code>@import("std")</code>) has architecture, environment, and operating sytsem
7460 The Zig Standard Library ({#syntax#}@import("std"){#endsyntax#}) has architecture, environment, and operating sytsem
74587461 abstractions, and thus takes additional work to support more platforms.
74597462 Not all standard library code requires operating system abstractions, however,
74607463 so things such as generic data structures work an all above platforms.
......@@ -7491,25 +7494,25 @@ coding style.
74917494 {#header_close#}
74927495 {#header_open|Names#}
74937496 <p>
7494 Roughly speaking: <code>camelCaseFunctionName</code>, <code>TitleCaseTypeName</code>,
7495 <code>snake_case_variable_name</code>. More precisely:
7497 Roughly speaking: {#syntax#}camelCaseFunctionName{#endsyntax#}, {#syntax#}TitleCaseTypeName{#endsyntax#},
7498 {#syntax#}snake_case_variable_name{#endsyntax#}. More precisely:
74967499 </p>
74977500 <ul>
74987501 <li>
7499 If <code>x</code> is a <code>struct</code> (or an alias of a <code>struct</code>),
7500 then <code>x</code> should be <code>TitleCase</code>.
7502 If {#syntax#}x{#endsyntax#} is a {#syntax#}struct{#endsyntax#} (or an alias of a {#syntax#}struct{#endsyntax#}),
7503 then {#syntax#}x{#endsyntax#} should be {#syntax#}TitleCase{#endsyntax#}.
75017504 </li>
75027505 <li>
7503 If <code>x</code> otherwise identifies a type, <code>x</code> should have <code>snake_case</code>.
7506 If {#syntax#}x{#endsyntax#} otherwise identifies a type, {#syntax#}x{#endsyntax#} should have {#syntax#}snake_case{#endsyntax#}.
75047507 </li>
75057508 <li>
7506 If <code>x</code> is callable, and <code>x</code>'s return type is <code>type</code>, then <code>x</code> should be <code>TitleCase</code>.
7509 If {#syntax#}x{#endsyntax#} is callable, and {#syntax#}x{#endsyntax#}'s return type is {#syntax#}type{#endsyntax#}, then {#syntax#}x{#endsyntax#} should be {#syntax#}TitleCase{#endsyntax#}.
75077510 </li>
75087511 <li>
7509 If <code>x</code> is otherwise callable, then <code>x</code> should be <code>camelCase</code>.
7512 If {#syntax#}x{#endsyntax#} is otherwise callable, then {#syntax#}x{#endsyntax#} should be {#syntax#}camelCase{#endsyntax#}.
75107513 </li>
75117514 <li>
7512 Otherwise, <code>x</code> should be <code>snake_case</code>.
7515 Otherwise, {#syntax#}x{#endsyntax#} should be {#syntax#}snake_case{#endsyntax#}.
75137516 </li>
75147517 </ul>
75157518 <p>
......@@ -7521,7 +7524,7 @@ coding style.
75217524 <p>
75227525 These are general rules of thumb; if it makes sense to do something different,
75237526 do what makes sense. For example, if there is an established convention such as
7524 <code>ENOENT</code>, follow the established convention.
7527 {#syntax#}ENOENT{#endsyntax#}, follow the established convention.
75257528 </p>
75267529 {#header_close#}
75277530 {#header_open|Examples#}