mlld
Version:
mlld: llm scripting language
39 lines (31 loc) • 847 B
Markdown
---
id: while
title: While Loops
brief: Bounded iteration with done/continue control
category: control-flow
tags: [iteration, loops]
related: [for-arrow]
related-code: [interpreter/eval/while.ts]
updated: 2026-01-05
---
Bounded iteration with `while`.
```mlld
exe = when [
<= 0 => done "finished"
* => continue ( - 1)
]
var = 5 | while(10)
```
**Control keywords:**
- `done ` - Terminate, return value
- `done` - Terminate, return current state
- `continue ` - Next iteration with new state
- `continue` - Next iteration with current state
**While context** (`.while`):
- `iteration` - Current iteration (1-based)
- `limit` - Configured cap
- `active` - true when inside while
**With pacing:**
```mlld
var = | while(100, 1s) >> 1s between iterations
```