Koka-inspired local mutable variables for cleaner comprehensions

Thanks everyone for your inputs. I will close this proposal soon and resubmit it without mentioning mutability. There are two aspects to decide:

  1. What should we call them? Local state? Local accumulators?

  2. We definitely need explicit syntax to declare them, such as the mut “keyword”, do we also need explicit syntax to reassign them? I am personally undecided. F# does use a different syntax, as @billylanchantin mentioned, but in F# it is literally mutable and it crosses the local scope, which is why you need a different syntax. One of the reasons to not have different syntax is: what if you write {foo, bar} = some_fun() where foo is a mutable (as in this proposal) but bar is not? Using a separate operator would not capture this nuance. Using a sigil such as $foo is an alternative but it has a much bigger footprint on the language. Anyway, we don’t need to decide this now, but it is food for thought.

I’d say only here is a red herring, readability is extremely important and it should be enough reason. :slight_smile:

7 Likes