Skip to content

Conversation

@HMarcien
Copy link

This PR updates the documentation for the main imperative loop constructs provided by Gerbil: do, do-while, while, and until.

Each entry is organized into the following logical sections:

  1. Signature: The full technical signature of the form.
  2. Summary: A single, high-level sentence explaining its core purpose.
  3. Description: A detailed explanation of its behavior, arguments, return value, and edge cases.
  4. Example(s): Practical, self-contained examples demonstrating common use cases.
  5. Context and Usage: A crucial section explaining why and when to use this form compared to alternatives.
  6. See Also: Links to related forms to improve discoverability.

Note: English is not my native language (I’m a French speaker). The text was written with the help of Gemini and Google Translate.

Copy link
Collaborator

@vyzo vyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite good, thank you!

Just a small nit about the trailing :s in tip boxes.

4. If `test` is false, the `command` expressions in the loop body are evaluated in order.
5. Finally, the `step` expressions for each variable are evaluated. All `step` expressions are computed using the variable values from the previous iteration. After all steps are computed, the variables are simultaneously updated with their new values, and the loop proceeds to the next iteration (starting again at step 2).

::: tip Examples:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for the trailing : (just Examples), the renderer will create a tip box.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

4. If `test` is truthy, the `step` expressions are evaluated to compute the new values for the variables, and the loop continues from step 2.
5. If `test` is false, the loop terminates. The `result` expressions are then evaluated, and the value of the last one is returned.

::: tip Example:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


This behavior means the loop body may be executed **zero or more times**. If the initial `test` is false, the body will never be executed. The `while` macro always returns a void value.

::: tip Example:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here


Like [`while`](#while), the loop body may be executed **zero or more times**. The `until` macro always returns a void value.

::: tip Example:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here

@HMarcien HMarcien requested a review from vyzo September 18, 2025 19:26
Copy link
Collaborator

@vyzo vyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@vyzo vyzo merged commit 913fc26 into mighty-gerbils:documentation-updates Sep 18, 2025
4 checks passed
@HMarcien HMarcien deleted the doc-loop-expressions branch September 18, 2025 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants