Examples

locals.mul

Variables and blocks (RFC-005): let is immutable, var can be assigned, a block opens a scope. MUL has no shadowing.

Source

examples/locals.mul is stored in the compact layout, as AI agents write it: a space only between two words, no other whitespace. The page lays it out for reading; the Compact button shows the stored text, and Copy always copies it.

// Variables and blocks (RFC-005): `let` is immutable, `var` can be assigned,
// a block opens a scope. MUL has no shadowing.
module demo fn price(net:i32,qty:i32)->i32{let taxPercent=23 var total=net*qty{let tax=total*taxPercent/100 total=total+tax}return total}pub fn main()->i32{return price(250,4)}

Verified IR

What mul ir prints after the verifier has accepted the program.

module demo

fn @price(%0: i32, %1: i32) -> i32 {
b0:
  %2 = const.i32 23
  %3 = mul.i32 %0, %1
  %4 = mul.i32 %3, %2
  %5 = const.i32 100
  %6 = div.i32 %4, %5
  %7 = add.i32 %3, %6
  return %7
}

fn @main() -> i32 {
b0:
  %0 = const.i32 250
  %1 = const.i32 4
  %2 = call.i32 @price(%0, %1)
  return %2
}

Run

The value main returns is the exit code of the process.

$ mul run examples/locals.mul; echo "exit code $?"
exit code 206