var/mutability syntax ===================== How to indicate...: * that a variable value can be "replaced" / "pointed to something else"? * that what the variable references can be modified? * that a function call replaces: - a parameter? * that a function call modifies: - it's object? - a parameter? * that a function can perform I/O? * that a variable's type's method's can perform I/O if declared as being able to do so? Current solution ---------------- The current SLUL-try2 code uses the `!` character as a sigill, but there are some minor issues with that: * sigills such as `!` for modifiability and `@` for I/O might not be intuitive? On the other hand, you're going to see `@File` almost everytime you see something-`File`, so it might be something you learn easilly by memorization (similar to how many human languages have different grammar (often called "gender") for different words). * it doesn't support out-parameters (but this might be a non-issue with multiple return values) Syntax options -------------- var T var o var T io f a single keyword placed in different places replaceable modifiable T o replaceable io T f different intuitive keywords (but those are quite long) mrvar T o irvar T f different keywords distinguished by prefix letters var mut T o var io T f synonym keywords with non-intuitive difference !T !o @T !f sigills VarT !o IOT !f type prefixes + identifier sigills VarT varO IOT varF type prefixes + identifier prefixes !T o <- ... @T f <- ... type sigills + different operators (`=` vs `<-`) var T o <- ... io T f <- ... keywords + different operators (`=` vs `<-`) var T o <- ... io T f <- ... replaceable keywords + different operators (`=` vs `<-`) var T o.. io T f.. var T o = nonfinal ... io T f = nonfinal ... is there a shorter keyword? nonfinal changeable changable replacable nonlast temp vary (...but confusingly similar to var) var T o nonfinal io T f nonfinal # Alternative solution with 3 modes var int i modifiable T a replaceable T b replaceable modifiable T c Old stuff --------- Regarding <- syntax: 1. How to distinguish between replaceable vs non-replaceable variables when there's no initial value? - Maybe the variable could start out as "replaceable". - Pros: Flexible. - Cons: It becomes harder to mentally analyze code. - Or require an explicit `<- unset` for replaceable variables? - This might actually be somewhat readable as well. 2. How to distinguish between replaceable vs non-replaceable fields? - Could also have initial values (including `<- unset`). (Maybe this is actually quite logical, as everything else will have to be initialized in the constructor.) Regarding += and array/map element assignment: # How to distinguish between final and non-final assignment? a += 1 arr 1 = 1 map k v += 1 Assigning to a field or element (or anything else that's not a plain local variable) is always a non-final assignment. But how should the syntax be? ... maybe <- is better? Maybe <- could be tokenized as < - if it doesn't appear in an assignment? But how about e.g. `a <- b <- c` ? Someone might write that, and then it wouldn't do what you expected. And this still doesn't solve the issue with +=