| ... | @@ -10308,14 +10308,568 @@ fn readU32Be() u32 {} | ... | @@ -10308,14 +10308,568 @@ fn readU32Be() u32 {} |
| 10308 | {#header_close#} | 10308 | {#header_close#} |
| 10309 | | 10309 | |
| 10310 | {#header_open|Keyword Reference#} | 10310 | {#header_open|Keyword Reference#} |
| 10311 | <p> | 10311 | <table> |
| 10312 | TODO the rest of the keywords. Most of these can just be links to the relevant section. | 10312 | <tr> |
| 10313 | </p> | 10313 | <th> |
| 10314 | {#header_open|Keyword: pub#} | 10314 | Keyword |
| 10315 | <p>The {#syntax#}pub{#endsyntax#} in front of a top level declaration makes the | 10315 | </th> |
| 10316 | declaration available to reference from a different file than the one it is declared in.</p> | 10316 | <th> |
| 10317 | {#see_also|@import#} | 10317 | Description |
| 10318 | {#header_close#} | 10318 | </th> |
| | 10319 | </tr> |
| | 10320 | <tr> |
| | 10321 | <td> |
| | 10322 | <pre>{#syntax#}align{#endsyntax#}</pre> |
| | 10323 | </td> |
| | 10324 | <td> |
| | 10325 | {#syntax#}align{#endsyntax#} can be used to specify the alignment of a pointer. It can also be used after a variable or function declaration to specify the alignment of pointers to that variable or function. |
| | 10326 | <ul> |
| | 10327 | <li>See also {#link|Alignment#}</li> |
| | 10328 | </ul> |
| | 10329 | </td> |
| | 10330 | </tr> |
| | 10331 | <tr> |
| | 10332 | <td> |
| | 10333 | <pre>{#syntax#}allowzero{#endsyntax#}</pre> |
| | 10334 | </td> |
| | 10335 | <td> |
| | 10336 | The pointer attribute {#syntax#}allowzero{#endsyntax#} allows a pointer to have address zero. |
| | 10337 | <ul> |
| | 10338 | <li>See also {#link|allowzero#}</li> |
| | 10339 | </ul> |
| | 10340 | </td> |
| | 10341 | </tr> |
| | 10342 | <tr> |
| | 10343 | <td> |
| | 10344 | <pre>{#syntax#}and{#endsyntax#}</pre> |
| | 10345 | </td> |
| | 10346 | <td> |
| | 10347 | The boolean operator {#syntax#}and{#endsyntax#}. |
| | 10348 | <ul> |
| | 10349 | <li>See also {#link|Operators#}</li> |
| | 10350 | </ul> |
| | 10351 | </td> |
| | 10352 | </tr> |
| | 10353 | <tr> |
| | 10354 | <td> |
| | 10355 | <pre>{#syntax#}anyframe{#endsyntax#}</pre> |
| | 10356 | </td> |
| | 10357 | <td> |
| | 10358 | {#syntax#}anyframe{#endsyntax#} can be used as a type for variables which hold pointers to function frames. |
| | 10359 | <ul> |
| | 10360 | <li>See also {#link|Async Functions#}</li> |
| | 10361 | </ul> |
| | 10362 | </td> |
| | 10363 | </tr> |
| | 10364 | <tr> |
| | 10365 | <td> |
| | 10366 | <pre>{#syntax#}anytype{#endsyntax#}</pre> |
| | 10367 | </td> |
| | 10368 | <td> |
| | 10369 | Function parameters can be declared with {#syntax#}anytype{#endsyntax#} in place of the type. The parameter type will be inferred where the function is called. |
| | 10370 | <ul> |
| | 10371 | <li>See also {#link|Function Parameter Type Inference#}</li> |
| | 10372 | </ul> |
| | 10373 | </td> |
| | 10374 | </tr> |
| | 10375 | <tr> |
| | 10376 | <td> |
| | 10377 | <pre>{#syntax#}asm{#endsyntax#}</pre> |
| | 10378 | </td> |
| | 10379 | <td> |
| | 10380 | {#syntax#}asm{#endsyntax#} begins an inline assembly expression. This allows for directly controlling the machine code generated on compilation. |
| | 10381 | <ul> |
| | 10382 | <li>See also {#link|Assembly#}</li> |
| | 10383 | </ul> |
| | 10384 | </td> |
| | 10385 | </tr> |
| | 10386 | <tr> |
| | 10387 | <td> |
| | 10388 | <pre>{#syntax#}async{#endsyntax#}</pre> |
| | 10389 | </td> |
| | 10390 | <td> |
| | 10391 | {#syntax#}async{#endsyntax#} can be used before a function call to get a pointer to the function's frame when it suspends. |
| | 10392 | <ul> |
| | 10393 | <li>See also {#link|Async Functions#}</li> |
| | 10394 | </ul> |
| | 10395 | </td> |
| | 10396 | </tr> |
| | 10397 | <tr> |
| | 10398 | <td> |
| | 10399 | <pre>{#syntax#}await{#endsyntax#}</pre> |
| | 10400 | </td> |
| | 10401 | <td> |
| | 10402 | {#syntax#}await{#endsyntax#} can be used to suspend the current function until the frame provided after the {#syntax#}await{#endsyntax#} completes. {#syntax#}await{#endsyntax#} copies the value returned from the target function's frame to the caller. |
| | 10403 | <ul> |
| | 10404 | <li>See also {#link|Async Functions#}</li> |
| | 10405 | </ul> |
| | 10406 | </td> |
| | 10407 | </tr> |
| | 10408 | <tr> |
| | 10409 | <td> |
| | 10410 | <pre>{#syntax#}break{#endsyntax#}</pre> |
| | 10411 | </td> |
| | 10412 | <td> |
| | 10413 | {#syntax#}break{#endsyntax#} can be used to exit a loop before iteration completes naturally. |
| | 10414 | It can also be used with a block label to return a value from the block. |
| | 10415 | <ul> |
| | 10416 | <li>See also {#link|blocks#}, {#link|while#}, {#link|for#}</li> |
| | 10417 | </ul> |
| | 10418 | </td> |
| | 10419 | </tr> |
| | 10420 | <tr> |
| | 10421 | <td> |
| | 10422 | <pre>{#syntax#}catch{#endsyntax#}</pre> |
| | 10423 | </td> |
| | 10424 | <td> |
| | 10425 | {#syntax#}catch{#endsyntax#} can be used to provide a default value for an error union, or capture its error value in an expression. |
| | 10426 | <ul> |
| | 10427 | <li>See also {#link|catch#}, {#link|Operators#}</li> |
| | 10428 | </ul> |
| | 10429 | </td> |
| | 10430 | </tr> |
| | 10431 | <tr> |
| | 10432 | <td> |
| | 10433 | <pre>{#syntax#}comptime{#endsyntax#}</pre> |
| | 10434 | </td> |
| | 10435 | <td> |
| | 10436 | {#syntax#}comptime{#endsyntax#} before a declaration can be used to label variables or function parameters as known at compile time. |
| | 10437 | It can also be used to guarantee an expression is run at compile time. |
| | 10438 | <ul> |
| | 10439 | <li>See also {#link|comptime#}</li> |
| | 10440 | </ul> |
| | 10441 | </td> |
| | 10442 | </tr> |
| | 10443 | <tr> |
| | 10444 | <td> |
| | 10445 | <pre>{#syntax#}const{#endsyntax#}</pre> |
| | 10446 | </td> |
| | 10447 | <td> |
| | 10448 | {#syntax#}const{#endsyntax#} declares a variable that can not be modified. |
| | 10449 | <ul> |
| | 10450 | <li>See also {#link|Variables#}</li> |
| | 10451 | </ul> |
| | 10452 | </td> |
| | 10453 | </tr> |
| | 10454 | <tr> |
| | 10455 | <td> |
| | 10456 | <pre>{#syntax#}continue{#endsyntax#}</pre> |
| | 10457 | </td> |
| | 10458 | <td> |
| | 10459 | {#syntax#}continue{#endsyntax#} can be used in a loop to jump back to the beginning of the loop. |
| | 10460 | <ul> |
| | 10461 | <li>See also {#link|while#}, {#link|for#}</li> |
| | 10462 | </ul> |
| | 10463 | </td> |
| | 10464 | </tr> |
| | 10465 | <tr> |
| | 10466 | <td> |
| | 10467 | <pre>{#syntax#}defer{#endsyntax#}</pre> |
| | 10468 | </td> |
| | 10469 | <td> |
| | 10470 | {#syntax#}defer{#endsyntax#} will execute an expression at the end of the current block. |
| | 10471 | <ul> |
| | 10472 | <li>See also {#link|defer#}</li> |
| | 10473 | </ul> |
| | 10474 | </td> |
| | 10475 | </tr> |
| | 10476 | <tr> |
| | 10477 | <td> |
| | 10478 | <pre>{#syntax#}else{#endsyntax#}</pre> |
| | 10479 | </td> |
| | 10480 | <td> |
| | 10481 | {#syntax#}else{#endsyntax#} can be used to provide an alternate branch for {#syntax#}if{#endsyntax#}, {#syntax#}switch{#endsyntax#}, {#syntax#}while{#endsyntax#}, and {#syntax#}for{#endsyntax#} expressions. |
| | 10482 | <ul> |
| | 10483 | <li>If used after an if expression, the else branch will be executed if the test value returns false, null, or an error.</li> |
| | 10484 | <li>If used within a switch expression, the else branch will be executed if the test value matches no other cases.</li> |
| | 10485 | <li>If used after a loop expression, the else branch will be executed if the loop finishes without breaking.</li> |
| | 10486 | <li>See also {#link|if#}, {#link|switch#}, {#link|while#}, {#link|for#}</li> |
| | 10487 | </ul> |
| | 10488 | </td> |
| | 10489 | </tr> |
| | 10490 | <tr> |
| | 10491 | <td> |
| | 10492 | <pre>{#syntax#}enum{#endsyntax#}</pre> |
| | 10493 | </td> |
| | 10494 | <td> |
| | 10495 | {#syntax#}enum{#endsyntax#} defines an anonymous enum type. |
| | 10496 | <ul> |
| | 10497 | <li>See also {#link|enum#}</li> |
| | 10498 | </ul> |
| | 10499 | </td> |
| | 10500 | </tr> |
| | 10501 | <tr> |
| | 10502 | <td> |
| | 10503 | <pre>{#syntax#}errdefer{#endsyntax#}</pre> |
| | 10504 | </td> |
| | 10505 | <td> |
| | 10506 | {#syntax#}errdefer{#endsyntax#} will execute an expression at the end of the current block if and only if the block returns an error. |
| | 10507 | <ul> |
| | 10508 | <li>See also {#link|errdefer#}</li> |
| | 10509 | </ul> |
| | 10510 | </td> |
| | 10511 | </tr> |
| | 10512 | <tr> |
| | 10513 | <td> |
| | 10514 | <pre>{#syntax#}error{#endsyntax#}</pre> |
| | 10515 | </td> |
| | 10516 | <td> |
| | 10517 | {#syntax#}error{#endsyntax#} defines an anonymous error type. |
| | 10518 | <ul> |
| | 10519 | <li>See also {#link|Errors#}</li> |
| | 10520 | </ul> |
| | 10521 | </td> |
| | 10522 | </tr> |
| | 10523 | <tr> |
| | 10524 | <td> |
| | 10525 | <pre>{#syntax#}export{#endsyntax#}</pre> |
| | 10526 | </td> |
| | 10527 | <td> |
| | 10528 | {#syntax#}export{#endsyntax#} makes a function externally visible in the generated object file, and makes it use the C ABI. |
| | 10529 | <ul> |
| | 10530 | <li>See also {#link|Functions#}</li> |
| | 10531 | </ul> |
| | 10532 | </td> |
| | 10533 | </tr> |
| | 10534 | <tr> |
| | 10535 | <td> |
| | 10536 | <pre>{#syntax#}extern{#endsyntax#}</pre> |
| | 10537 | </td> |
| | 10538 | <td> |
| | 10539 | {#syntax#}extern{#endsyntax#} can be used to declare a function that will be resolved at link time, when linking statically, or at runtime, when linking dynamically. |
| | 10540 | <ul> |
| | 10541 | <li>See also {#link|Functions#}</li> |
| | 10542 | </ul> |
| | 10543 | </td> |
| | 10544 | </tr> |
| | 10545 | <tr> |
| | 10546 | <td> |
| | 10547 | <pre>{#syntax#}false{#endsyntax#}</pre> |
| | 10548 | </td> |
| | 10549 | <td> |
| | 10550 | The boolean value {#syntax#}false{#endsyntax#}. |
| | 10551 | <ul> |
| | 10552 | <li>See also {#link|Primitive Values#}</li> |
| | 10553 | </ul> |
| | 10554 | </td> |
| | 10555 | </tr> |
| | 10556 | <tr> |
| | 10557 | <td> |
| | 10558 | <pre>{#syntax#}fn{#endsyntax#}</pre> |
| | 10559 | </td> |
| | 10560 | <td> |
| | 10561 | {#syntax#}fn{#endsyntax#} declares a function. |
| | 10562 | <ul> |
| | 10563 | <li>See also {#link|Functions#}</li> |
| | 10564 | </ul> |
| | 10565 | </td> |
| | 10566 | </tr> |
| | 10567 | <tr> |
| | 10568 | <td> |
| | 10569 | <pre>{#syntax#}for{#endsyntax#}</pre> |
| | 10570 | </td> |
| | 10571 | <td> |
| | 10572 | A {#syntax#}for{#endsyntax#} expression can be used to iterate over the elements of a slice or array. |
| | 10573 | <ul> |
| | 10574 | <li>See also {#link|for#}</li> |
| | 10575 | </ul> |
| | 10576 | </td> |
| | 10577 | </tr> |
| | 10578 | <tr> |
| | 10579 | <td> |
| | 10580 | <pre>{#syntax#}if{#endsyntax#}</pre> |
| | 10581 | </td> |
| | 10582 | <td> |
| | 10583 | An {#syntax#}if{#endsyntax#} expression can test boolean expressions, optional values, or error unions. |
| | 10584 | For optional values or error unions, the if expression can capture the unwrapped value. |
| | 10585 | <ul> |
| | 10586 | <li>See also {#link|if#}</li> |
| | 10587 | </ul> |
| | 10588 | </td> |
| | 10589 | </tr> |
| | 10590 | <tr> |
| | 10591 | <td> |
| | 10592 | <pre>{#syntax#}inline{#endsyntax#}</pre> |
| | 10593 | </td> |
| | 10594 | <td> |
| | 10595 | {#syntax#}inline{#endsyntax#} can be used to label a loop expression such that it will be unrolled at compile time. |
| | 10596 | It can also be used to force a function to be inlined at all call sites. |
| | 10597 | <ul> |
| | 10598 | <li>See also {#link|inline while#}, {#link|inline for#}, {#link|Functions#}</li> |
| | 10599 | </ul> |
| | 10600 | </td> |
| | 10601 | </tr> |
| | 10602 | <tr> |
| | 10603 | <td> |
| | 10604 | <pre>{#syntax#}noalias{#endsyntax#}</pre> |
| | 10605 | </td> |
| | 10606 | <td> |
| | 10607 | The {#syntax#}noalias{#endsyntax#} keyword. |
| | 10608 | <ul> |
| | 10609 | <li>TODO add documentation for noalias</li> |
| | 10610 | </ul> |
| | 10611 | </td> |
| | 10612 | </tr> |
| | 10613 | <tr> |
| | 10614 | <td> |
| | 10615 | <pre>{#syntax#}nosuspend{#endsyntax#}</pre> |
| | 10616 | </td> |
| | 10617 | <td> |
| | 10618 | The {#syntax#}nosuspend{#endsyntax#} keyword. |
| | 10619 | <ul> |
| | 10620 | <li>TODO add documentation for nosuspend</li> |
| | 10621 | </ul> |
| | 10622 | </td> |
| | 10623 | </tr> |
| | 10624 | <tr> |
| | 10625 | <td> |
| | 10626 | <pre>{#syntax#}null{#endsyntax#}</pre> |
| | 10627 | </td> |
| | 10628 | <td> |
| | 10629 | The optional value {#syntax#}null{#endsyntax#}. |
| | 10630 | <ul> |
| | 10631 | <li>See also {#link|null#}</li> |
| | 10632 | </ul> |
| | 10633 | </td> |
| | 10634 | </tr> |
| | 10635 | <tr> |
| | 10636 | <td> |
| | 10637 | <pre>{#syntax#}or{#endsyntax#}</pre> |
| | 10638 | </td> |
| | 10639 | <td> |
| | 10640 | The boolean operator {#syntax#}or{#endsyntax#}. |
| | 10641 | <ul> |
| | 10642 | <li>See also {#link|Operators#}</li> |
| | 10643 | </ul> |
| | 10644 | </td> |
| | 10645 | </tr> |
| | 10646 | <tr> |
| | 10647 | <td> |
| | 10648 | <pre>{#syntax#}orelse{#endsyntax#}</pre> |
| | 10649 | </td> |
| | 10650 | <td> |
| | 10651 | {#syntax#}orelse{#endsyntax#} can be used to provide a default value for an optional expression if it evaluates to null. |
| | 10652 | <ul> |
| | 10653 | <li>See also {#link|Optionals#}, {#link|Operators#}</li> |
| | 10654 | </ul> |
| | 10655 | </td> |
| | 10656 | </tr> |
| | 10657 | <tr> |
| | 10658 | <td> |
| | 10659 | <pre>{#syntax#}packed{#endsyntax#}</pre> |
| | 10660 | </td> |
| | 10661 | <td> |
| | 10662 | The {#syntax#}packed{#endsyntax#} keyword before a struct definition changes the struct's in-memory layout to the guaranteed {#syntax#}packed{#endsyntax#} layout. |
| | 10663 | <ul> |
| | 10664 | <li>See also {#link|packed struct#}</li> |
| | 10665 | </ul> |
| | 10666 | </td> |
| | 10667 | </tr> |
| | 10668 | <tr> |
| | 10669 | <td> |
| | 10670 | <pre>{#syntax#}pub{#endsyntax#}</pre> |
| | 10671 | </td> |
| | 10672 | <td> |
| | 10673 | The {#syntax#}pub{#endsyntax#} in front of a top level declaration makes the declaration available to reference from a different file than the one it is declared in. |
| | 10674 | <ul> |
| | 10675 | <li>See also {#link|import#}</li> |
| | 10676 | </ul> |
| | 10677 | </td> |
| | 10678 | </tr> |
| | 10679 | <tr> |
| | 10680 | <td> |
| | 10681 | <pre>{#syntax#}resume{#endsyntax#}</pre> |
| | 10682 | </td> |
| | 10683 | <td> |
| | 10684 | {#syntax#}resume{#endsyntax#} will continue execution of a function frame after the point the function was suspended. |
| | 10685 | <ul> |
| | 10686 | <li>See also {#link|Suspend and Resume#}</li> |
| | 10687 | </ul> |
| | 10688 | </td> |
| | 10689 | </tr> |
| | 10690 | <tr> |
| | 10691 | <td> |
| | 10692 | <pre>{#syntax#}return{#endsyntax#}</pre> |
| | 10693 | </td> |
| | 10694 | <td> |
| | 10695 | {#syntax#}return{#endsyntax#} exits a function with a value. |
| | 10696 | <ul> |
| | 10697 | <li>See also {#link|Functions#}</li> |
| | 10698 | </ul> |
| | 10699 | </td> |
| | 10700 | </tr> |
| | 10701 | <tr> |
| | 10702 | <td> |
| | 10703 | <pre>{#syntax#}linksection{#endsyntax#}</pre> |
| | 10704 | </td> |
| | 10705 | <td> |
| | 10706 | The {#syntax#}linksection{#endsyntax#} keyword. |
| | 10707 | <ul> |
| | 10708 | <li>TODO add documentation for linksection</li> |
| | 10709 | </ul> |
| | 10710 | </td> |
| | 10711 | </tr> |
| | 10712 | <tr> |
| | 10713 | <td> |
| | 10714 | <pre>{#syntax#}struct{#endsyntax#}</pre> |
| | 10715 | </td> |
| | 10716 | <td> |
| | 10717 | {#syntax#}struct{#endsyntax#} defines an anonymous struct. |
| | 10718 | <ul> |
| | 10719 | <li>See also {#link|struct#}</li> |
| | 10720 | </ul> |
| | 10721 | </td> |
| | 10722 | </tr> |
| | 10723 | <tr> |
| | 10724 | <td> |
| | 10725 | <pre>{#syntax#}suspend{#endsyntax#}</pre> |
| | 10726 | </td> |
| | 10727 | <td> |
| | 10728 | {#syntax#}suspend{#endsyntax#} will cause control flow to return to the call site or resumer of the function. |
| | 10729 | {#syntax#}suspend{#endsyntax#} can also be used before a block within a function, to allow the function access to it's frame before control flow returns to the call site. |
| | 10730 | <ul> |
| | 10731 | <li>See also {#link|Suspend and Resume#}</li> |
| | 10732 | </ul> |
| | 10733 | </td> |
| | 10734 | </tr> |
| | 10735 | <tr> |
| | 10736 | <td> |
| | 10737 | <pre>{#syntax#}switch{#endsyntax#}</pre> |
| | 10738 | </td> |
| | 10739 | <td> |
| | 10740 | A {#syntax#}switch{#endsyntax#} expression can be used to test values of a common type. {#syntax#}switch{#endsyntax#} cases can capture field values of a {#link|Tagged union#}. |
| | 10741 | <ul> |
| | 10742 | <li>See also {#link|switch#}</li> |
| | 10743 | </ul> |
| | 10744 | </td> |
| | 10745 | </tr> |
| | 10746 | <tr> |
| | 10747 | <td> |
| | 10748 | <pre>{#syntax#}test{#endsyntax#}</pre> |
| | 10749 | </td> |
| | 10750 | <td> |
| | 10751 | The {#syntax#}test{#endsyntax#} keyword can be used to denote a top-level block of code used to make sure behavior meets expectations. |
| | 10752 | <ul> |
| | 10753 | <li>See also {#link|Zig Test#}</li> |
| | 10754 | </ul> |
| | 10755 | </td> |
| | 10756 | </tr> |
| | 10757 | <tr> |
| | 10758 | <td> |
| | 10759 | <pre>{#syntax#}threadlocal{#endsyntax#}</pre> |
| | 10760 | </td> |
| | 10761 | <td> |
| | 10762 | {#syntax#}threadlocal{#endsyntax#} can be used to specify a variable as thread-local. |
| | 10763 | <ul> |
| | 10764 | <li>See also {#link|Thread Local Variables#}</li> |
| | 10765 | </ul> |
| | 10766 | </td> |
| | 10767 | </tr> |
| | 10768 | <tr> |
| | 10769 | <td> |
| | 10770 | <pre>{#syntax#}true{#endsyntax#}</pre> |
| | 10771 | </td> |
| | 10772 | <td> |
| | 10773 | The boolean value {#syntax#}true{#endsyntax#}. |
| | 10774 | <ul> |
| | 10775 | <li>See also {#link|Primitive Values#}</li> |
| | 10776 | </ul> |
| | 10777 | </td> |
| | 10778 | </tr> |
| | 10779 | <tr> |
| | 10780 | <td> |
| | 10781 | <pre>{#syntax#}try{#endsyntax#}</pre> |
| | 10782 | </td> |
| | 10783 | <td> |
| | 10784 | {#syntax#}try{#endsyntax#} evaluates an error union expression. |
| | 10785 | If it is an error, it returns from the current function with the same error. |
| | 10786 | Otherwise, the expression results in the unwrapped value. |
| | 10787 | <ul> |
| | 10788 | <li>See also {#link|try#}</li> |
| | 10789 | </ul> |
| | 10790 | </td> |
| | 10791 | </tr> |
| | 10792 | <tr> |
| | 10793 | <td> |
| | 10794 | <pre>{#syntax#}undefined{#endsyntax#}</pre> |
| | 10795 | </td> |
| | 10796 | <td> |
| | 10797 | {#syntax#}undefined{#endsyntax#} can be used to leave a value uninitialized. |
| | 10798 | <ul> |
| | 10799 | <li>See also {#link|undefined#}</li> |
| | 10800 | </ul> |
| | 10801 | </td> |
| | 10802 | </tr> |
| | 10803 | <tr> |
| | 10804 | <td> |
| | 10805 | <pre>{#syntax#}union{#endsyntax#}</pre> |
| | 10806 | </td> |
| | 10807 | <td> |
| | 10808 | {#syntax#}union{#endsyntax#} defines an anonymous union. |
| | 10809 | <ul> |
| | 10810 | <li>See also {#link|union#}</li> |
| | 10811 | </ul> |
| | 10812 | </td> |
| | 10813 | </tr> |
| | 10814 | <tr> |
| | 10815 | <td> |
| | 10816 | <pre>{#syntax#}unreachable{#endsyntax#}</pre> |
| | 10817 | </td> |
| | 10818 | <td> |
| | 10819 | Depending on the build mode, {#syntax#}unreachable{#endsyntax#} may emit a panic. |
| | 10820 | <ul> |
| | 10821 | <li>Emits a panic in {#syntax#}Debug{#endsyntax#} and {#syntax#}ReleaseSafe{#endsyntax#} mode, or when using <code>zig test</code>.</li> |
| | 10822 | <li>Does not emit a panic in {#syntax#}ReleaseFast{#endsyntax#} mode, unless <code>zig test</code> is being used.</li> |
| | 10823 | <li>See also {#link|unreachable#}</li> |
| | 10824 | </ul> |
| | 10825 | </td> |
| | 10826 | </tr> |
| | 10827 | <tr> |
| | 10828 | <td> |
| | 10829 | <pre>{#syntax#}usingnamespace{#endsyntax#}</pre> |
| | 10830 | </td> |
| | 10831 | <td> |
| | 10832 | {#syntax#}usingnamespace{#endsyntax#} is a top-level declaration that imports all the public declarations of the operand, which must be a struct, union, or enum, into the current scope. |
| | 10833 | <ul> |
| | 10834 | <li>See also {#link|usingnamespace#}</li> |
| | 10835 | </ul> |
| | 10836 | </td> |
| | 10837 | </tr> |
| | 10838 | <tr> |
| | 10839 | <td> |
| | 10840 | <pre>{#syntax#}var{#endsyntax#}</pre> |
| | 10841 | </td> |
| | 10842 | <td> |
| | 10843 | {#syntax#}var{#endsyntax#} declares a variable that may be modified. |
| | 10844 | <ul> |
| | 10845 | <li>See also {#link|Variables#}</li> |
| | 10846 | </ul> |
| | 10847 | </td> |
| | 10848 | </tr> |
| | 10849 | <tr> |
| | 10850 | <td> |
| | 10851 | <pre>{#syntax#}volatile{#endsyntax#}</pre> |
| | 10852 | </td> |
| | 10853 | <td> |
| | 10854 | {#syntax#}volatile{#endsyntax#} can be used to denote loads or stores of a pointer have side effects. |
| | 10855 | It can also modify an inline assembly expression to denote it has side effects. |
| | 10856 | <ul> |
| | 10857 | <li>See also {#link|volatile#}, {#link|Assembly#}</li> |
| | 10858 | </ul> |
| | 10859 | </td> |
| | 10860 | </tr> |
| | 10861 | <tr> |
| | 10862 | <td> |
| | 10863 | <pre>{#syntax#}while{#endsyntax#}</pre> |
| | 10864 | </td> |
| | 10865 | <td> |
| | 10866 | A {#syntax#}while{#endsyntax#} expression can be used to repeatedly test a boolean, optional, or error union expression, and cease looping when that expression evaluates to false, null, or an error, respectively. |
| | 10867 | <ul> |
| | 10868 | <li>See also {#link|while#}</li> |
| | 10869 | </ul> |
| | 10870 | </td> |
| | 10871 | </tr> |
| | 10872 | </table> |
| 10319 | {#header_close#} | 10873 | {#header_close#} |
| 10320 | | 10874 | |
| 10321 | {#header_open|Grammar#} | 10875 | {#header_open|Grammar#} |