Open gavr123456789 opened 3 weeks ago
mut person = Person age: 42
person msgThatMutatesAge // all good
person = Person age: 42
person birthday // ERROR, person is immutable, declare mut
mut Person birthday = [
age <- age inc
]
This can be an alternative to methods for mut types, or addition.
Person birthday = [
age <- age + 1 // ERROR, rename method to birthday!
]
person birthday! // now u see its mutates
Person somethind = [
this birthday! // ERROR, birthday mutates so u need to rename to somethind!
]
Pros:
It would be cool to have a better way to mark reciever as mutable.
But it looks good with extend syntax:
Also, maybe the fact that it looks bad is actually a good thing?, since hallo, mutations are bad.
This change will make all the mutations local to the very root of evaluation.
Wanna mutate something somewhere? You shoud have a mutable reference there.