@vertigo Hmm....funny you discuss about mutable and immutable stuff. Two lines of thought I had about them:
ONE:
I once toyed with the idea of re-imagine Python's syntax using the # as an immutability prefix, and redefine various stuff like this (sorry, I do not know how to format it in monospace text in Mastodon):
#[ ... ] is just a tuple
[ ... ] is a mutable list just like before
#{ ... } is a frozen dict
{ ... } is a dict as usual,
#set(...) is a frozen set
set( ... ) us a set as usual
#"..." is a immutable string, like "..." in Python
"..." is somewhat similar to C string (mutable)
#bytes(...) is equivalent to bytes(...) in Python, while
bytes( ... ) is equivalent to bytearray(...) in Python
and so on. Actually, # is an operator; it turns any (compound) object into an immutable version, so it would work on structs, etc,
The reason why I thought about is because I got inspired from learning about React coding, which requires everything to be immutable to avoid getting slowed down in web page interaction with the user. (I once came across the demo showing the difference, which is quite dramatic). By using # prefix, it is easy to find mutable ones and eliminate them.
TWO:
I had thought about the idea of "locking" and "unlocking" the variable, which is closely related to immutability. It works like this:
i: integer; (* mutable *)
...
i := 7;
{ lock i;
some code using i, but can't change i
}
i := 8; (* out of scope, so now mutable *)
I forgot exactly why that idea popped in my mind, but that thought is with me.
I blather too much...so take it or ignore...