Idiom # 90: Read-only outside
All fields in Fuzion are automatically read-only from inside and form outside. So the task here is more to define a field that is mutable and a way to read this from the outside.
A mutable value has to be created using the
mut is a convenience feature to create a mutable value using the current mutate effect.
Updating the field from inside does work:
If you analyze the effects used by this code by hitting 'Effects!', you will
see that this code uses the
Updating the field from outside will cause a compile-time error:
In any case, the preferred way is not to update a field at all, but to create a new instance:
Note that field
f is not updated (which would require
set keyword, but there are two fields called
with a non-overlapping scope.