Control Flow and Schedule
Culsma supports loops, conditionals, and schedule-driven repetition.
Fixed Repetition
repeat 3 {
target << [source:5uL];
}The expression must be decidable for the repeat count.
Repeat counts may come from protocol parameters when they can be resolved while the plan is built:
protocol Wash(cycles = 3) {
repeat cycles {
target << [buffer:5uL];
}
}Schedule Repetition
repeat point in schedule(start = 30min, end = 120min, step = 30min) {
let obs = phy(sample = reactor, quantity = temperature);
}Inside the loop, point is bound to the current checkpoint value.
Schedule boundaries may also be parameterized:
protocol Observe(cycles = 35) {
repeat cycle in schedule(start = 1, end = cycles, step = 1) {
let obs = phy(sample = reactor, quantity = temperature);
}
}Discrete Schedule Forms
Use start, end, and step:
schedule(start = 1, end = 35, step = 1)
schedule(start = 30min, end = 120min, step = 30min)Or use explicit checkpoints:
schedule(at = [15min, 45min, 120min])The two forms are alternatives. Do not mix at=[...] with start/end/step in the same schedule.
Continuous Schedule Window
Continuous windows are explicit:
schedule(start = 0h, duration = 24h, mode = continuous, observe_every = 1h)Continuous schedules use start + (end | duration). They do not use step or at=[...].
Parameterized continuous windows are resolved at plan time:
protocol Perfuse(window = 24h) {
repeat perf in schedule(start = 0h, duration = window, mode = continuous) {
...
}
}Conditionals
if condition {
target << [source:5uL];
} else {
target << [buffer:5uL];
}The condition must be decidable by the compiler/runtime path that owns the values involved.
break and continue
continue; skips the remaining statements in the current loop iteration.
repeat 10 {
if skip_condition {
continue;
}
target << [source:1uL];
}break; exits the nearest enclosing repeat.
repeat 10 {
if stop_condition {
break;
}
target << [source:1uL];
}break and continue are only valid inside repeat blocks.
