Summary
Control flow in Point appears inside calculation and rule bodies: loops, accumulation, and conditionals in label blocks.
Syntax
Iteration
record Cart Item
unit price: Int
quantity: Int
rule line totals
input items: List<Cart Item>
output total: Int
total starts at 0
for each item in items
add item.unit price * item.quantity to total
return totalMutation in rules and calculations
rule adjust score
input score: Int
output total: Int
total starts at score
add 10 to total
subtract 5 from total
set total to 0
return totalConditional adds in rules
record Deploy Signals
has bundle id: Bool
rule deploy readiness
input signals: Deploy Signals
output score: Int
score starts at 0
add 30 when signals.has bundle id
return scoreLabels
label score status
input score: Int
output Text
when score >= 90 return "excellent"
otherwise return "keep going"Semantics
for each requires a List<T> iterable. Rule outputs initialized with starts at are mutable; calculation outputs using is are typically single assignment unless mutation forms are used.
Compiler note
for each requires a List<T>. Rule accumulators initialized with starts at may use add to, subtract from, and set to inside the body.
Example
From examples/cart-total.point:
module Checkout
record Cart Item
name: Text
unit price: Int
quantity: Int
rule cart total
input items: List<Cart Item>
output total: Int
total starts at 0
for each item in items
add item.unit price * item.quantity to total
return totalCommon mistakes
for eachover a non-list (iteration-type-mismatch)- Assigning to an immutable binding (
immutable-assignment)
Agent diagnostic notes
- Loop diagnostics point at the
for eachspan withrepairtext when the iterable is wrong - After fixing control flow, re-run
point check-jsonbefore touching unrelated blocks
