buzz
buzz copied to clipboard
Immutable objects
Either declare an object as immutable:
immut object Point {
int x,
int y,
}
And/Or declare an instance as immutable:
immut Point point = Point{
x = 10,
y = 10,
}
point.x = 20; | -> fails
Both would allow:
- object instances to be enum value
- interning of object instances and potentially speed up a lot of buzz code
And/Or declare fields as immutable #13
If we do https://github.com/buzz-language/buzz/issues/139 the keyword would need to specify mutability instead:
mut object Point {
int x,
int y,
}
| If we do it per instance + immutability by default we would have to say here that
| the variable is mutable and that the instance it contains is itself mutable.
| Not really elegant.
var mut Point point = Point{
x = 10,
y = 10,
}