Mamba is intended to function much like Python, and be a scripting language.
Therefore, users familiar with Python will typically expect that when they define a variable they can directly edit it.
High-level description of the feature
Instead of requiring that something be explicitly defined as mutable using the keyword 'mut', everything is mutable by default.
Instead, like in Java, we can explicitly define something as immutable by using the keyword 'fin. Unlike Java, however, when something is 'fin' (final), it is truly immutable, and its internal fields cannot be changed. This also means that for methods which takeselfas argument, we can define self asfin` so it will never change.
This is a bit of a difficult call to make, but I believe that considering the ecosystem of Python, Mamba should be more lenient.
However, this does mean that it is more likely that self will be mutable in a method, even when it shouldn't be.
Originally I wanted to prevent this, and took inspiration from Rust, but I think that Rust is perhaps more strict than what we're going for.
In short:
For short scripts, user's aren't burdened by needing the think about mutability.
For larger systems, users can consider using fin to make the system more maintainable as it were.
Description of potential implementation
-[ ] Drop 'mut' token
-[ ] Add 'fin' token
-[ ] Change behaviour in context/environment of type checker to deal with new tokens
Current Issue
Mamba is intended to function much like Python, and be a scripting language. Therefore, users familiar with Python will typically expect that when they define a variable they can directly edit it.
High-level description of the feature
Instead of requiring that something be explicitly defined as mutable using the keyword 'mut', everything is mutable by default. Instead, like in Java, we can explicitly define something as immutable by using the keyword 'fin
. Unlike Java, however, when something is 'fin' (final), it is truly immutable, and its internal fields cannot be changed. This also means that for methods which take
selfas argument, we can define self as
fin` so it will never change.This is a bit of a difficult call to make, but I believe that considering the ecosystem of Python, Mamba should be more lenient. However, this does mean that it is more likely that
self
will be mutable in a method, even when it shouldn't be. Originally I wanted to prevent this, and took inspiration from Rust, but I think that Rust is perhaps more strict than what we're going for. In short:fin
to make the system more maintainable as it were.Description of potential implementation
-[ ] Drop 'mut' token -[ ] Add 'fin' token -[ ] Change behaviour in context/environment of type checker to deal with new tokens