Control Flow
Control Flow
Thagore supports if, else, while, for, break, and continue. Conditions in if and while must always be wrapped in parentheses.
If and else
func choose(flag: bool, nested: bool) -> i32: if (flag): if (nested): return 1 else: return 2 else: return 3There is no dedicated elif keyword in the current compiler. Use else followed by another if when you need multiple branches.
While loops
func sum_to(limit: i32) -> i32: let index: i32 = 0 let total: i32 = 0 while (index < limit): total = total + index index = index + 1 return totalFor loops
for iterates over Array[T] values:
func sum_items(items: Array[i32]) -> i32: let total: i32 = 0 for item in items: total = total + item return totalIn current practice, arrays usually come from runtime-backed APIs such as std.io.read_ints or external/runtime code.
Early return
func classify(value: i32) -> i32: if (value < 0): return 1 let adjusted: i32 = value + 1 if (adjusted > 10): return 2 return 0Break and continue
break and continue are available inside loops:
func bounded_sum(limit: i32) -> i32: let i: i32 = 0 let total: i32 = 0 while (i < limit): i = i + 1 if (i == 2): continue if (i == 5): break total = total + i return totalThese forms are parsed and typechecked by the current compiler and are used by the drago codebase itself.