Open radrow opened 2 years ago
This would be a syntactic sugar that would possibly make it nicer to modify state fields (if it is a record, which is mostly the case).
record r = {val : int} record state = {x : int, y : r} stateful function f() = state.x = 21 state.y.val = 37
which would desugar to
put(state{x = 21}) put(state{y = state.y{val = 37}})
and ideally to
put(state{x = 21, y = state.y{val = 37}})
Note that state modifications are still explicit, as one needs to refer to the state as lvalue.
state
+1
I thought the compiler optimizes multiple puts into one at any rate.
oh yeah, I like this one! :)
This would be a syntactic sugar that would possibly make it nicer to modify state fields (if it is a record, which is mostly the case).
which would desugar to
and ideally to