Created mutability (markdown)

Simon Brooke 2017-01-02 16:32:20 +00:00
parent 75f44808ac
commit f34bca3b67

11
mutability.md Normal file

@ -0,0 +1,11 @@
I'm persuaded by working with Clojure that immutability of data is a really strong feature. But in a system which can evolve and change, some mutability is important. If an old, buggy version of a system function is replaced with a new, better version, user code should immediately and automatically use the better version. If Bill uses a piece of software written by Anne, and Anne updates her version, Bill should automatically see the new version - provided Anne allows him to.
Generally, adding a key value pair to a map should return a new map, with identical content to the old map except that in the new map, the specified key has the specified value. That means that anything which had a pointer to the old map still has a pointer to the old map.
Thus we need to make namespaces special, and what needs to be special about them is that the value of the canonical path to a namespace must always be the latest version of that namespace. That implies that changing the value of an existing key in a namespace must cause consequent changes to every namespace which points to that namespace (rebinding of the name of the child namespace in the parent to the new version), up to the root. That's a bit awkward and may become embarrassingly expensive. It also means we must include code to check for cycles in the namespace graph.
Given this, any fully qualified pathname of any object in any namespace will always retrieve the latest version; but a relative pathname from your current namespace may (will?) retrieve the value that was ruling at the time you last updated your reference to it (?).
I think something like this can be made to work, but I'm not certain!
See also [namespaces].