Immutable Value, Mutable Form

2 views
Skip to first unread message

William la Forge

unread,
Oct 1, 2015, 12:27:37 PM10/1/15
to AgileWikiDevelopers

A value can have more than one form or implementation. For example, a String and a char array may both represent the same value. Most objects, for example, can be serialized. Changing the form of a value then is not a change of value. This is the idea behind lazy deserialization / reserialization.

We can represent a data structure as a tree, where the values in the tree can be either the immutable value of the object or a read-only ByteBuffer holding the serialized form of the value, or both. Both forms can be held by nodes using atoms, so the form of the values can be changed without having to create a new tree. The value remains unchanged and the tree can be safely shared between threads. This is the core idea behind the lazy maps and vectors in the aatree project.

Reply all
Reply to author
Forward
0 new messages