Add to loop size array in data-types.md#41
Open
furidosu wants to merge 2 commits intoWerWolv:masterfrom
Open
Conversation
C3pa
reviewed
Nov 1, 2025
| u8 string[while(std::mem::read_unsigned($, 1) != 0xFF)] @ 0x00; | ||
| ``` | ||
|
|
||
| For more complex conditions, combine an array to `eof` with a struct containing `if` statements. Using `continue` would move on to the next array item of the loop; using `break` would stop the loop and the growing of the array. See also the [pattern control flow](control-flow.md#pattern-control-flow). |
Contributor
There was a problem hiding this comment.
Suggested change
| For more complex conditions, combine an array to `eof` with a struct containing `if` statements. Using `continue` would move on to the next array item of the loop; using `break` would stop the loop and the growing of the array. See also the [pattern control flow](control-flow.md#pattern-control-flow). | |
| For more complex conditions, set the array to grow until `eof` with a struct containing `if` statements. Using `continue` will move on to the next array item of the loop; using `break` will stop the loop and the growing of the array. See also the [pattern control flow](control-flow.md#pattern-control-flow). |
Contributor
There was a problem hiding this comment.
I am not sure what you are referring to by "Using continue would move on to the next array item of the loop; using break would stop the loop and the growing of the array."
If I am not mistaken, the following syntax: Command command_list[while(!std::mem::eof())] @ 0x00; doesn't permit using break or continue keywords since you can't specify the loop body.
Contributor
There was a problem hiding this comment.
Flow control is applied to the structs, not the array so for example you can do
enum Action : u8 {
Stop,
Skip,
Read
};
struct Command {
Action action;
if (action == Action::Stop)
break;
if (action== Action::Skip)
continue;
if (action == Action::Read)
u8 data[5];
};
Command command_list[while(!std::mem::eof())] @ 0x00;Maybe the example code should be simpler and better formatted
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.