As discussed in the previous article I want Spry to have a trivially accessible persistence mechanism enabling something similar to the Smalltalk image model, but based on a database. The memory organisation in Spry is basically nested Maps. After dwelling a bit on the inevitable hard question about modules and namespaces I have decided on a design that I hope will turn out simple and reasonably powerful!
Smalltalk has a Dictionary holding all the globals forming “the roots” of the object memory. In Smalltalk this Dictionary is also itself a global variable accessible as
Smalltalk, in other words
Smalltalk == (Smalltalk at: #Smalltalk). The primary use of
Smalltalk is to hold all classes by name, so they are all reachable as globals. Obviously
Smalltalk can also hold any kind of object (not just classes) as a global.
Spry also has such a top level Dictionary, but in Spry we call a Dictionary a
Map to be a little bit more aligned in terminology with other languages (and it’s shorter). This top level Map is the
root Map and it is accessible via the word
root. In Spry the
root word is actually bound to a primitive function returning this
Map, so in Spry we also have
root == (root at: 'root).
Ok, so Spry has a
Map of globals and one way of using Spry is simply by populating
root with words bound to functions making these functions globally accessible, it’s how I have done it so far. Yeah, yeah, I know, but for smaller systems it probably works just fine!