In this example, feature f does not have any visible effects apart from io.out, but it performs a state change to v
m : mutate is
m1 := m
v := m1.instate_self ()->
say "start"
r := m.env.new 42
say "r = $r"
r
# f uses no effects, but mutates `v`
f ! io.out =>
_ := m1.instate_self ()->
v <- 4711 + v
say "updated v via m1: $v"
f; f; f
which can be seen when running the code that produces different output
> ./build/bin/fz repeated_mutate1.fz
start
r = 42
updated v via m1: 4753
updated v via m1: 9464
updated v via m1: 14175
In this example, feature
f
does not have any visible effects apart fromio.out
, but it performs a state change tov
which can be seen when running the code that produces different output