Mutability

From Adam Colton
Revision as of 17:35, 17 September 2019 by Adamcolton (talk | contribs) (Created page with "Mutability will be explicit. Variables are mutable or immutable. == Mono Mute == One idea I like but I'm not sure about it's feasibility; there can only ever be one mutable ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Mutability will be explicit.

Variables are mutable or immutable.

Mono Mute

One idea I like but I'm not sure about it's feasibility; there can only ever be one mutable reference. For linear stack calls, this is easy. If we disallow any form of global mutable, it's also easy.

The only complicating factor is concurrency. If I have a mutable reference that I want to share with a concurrent call, then there's two references.

Case Study

How would you add a memoization wrapper? Specifically, to a concurrent Fibonacci call.

Expressions

It might be good to disallow mutable calls in expressions.

 if a.Foo() || a.Bar() {...}

If a.Bar can mutate a and || is evaluated lazily, this is a good spot for bugs to hide.