Skip to content

Commit 9290a53

Browse files
committed
Update design doc
1 parent 468c996 commit 9290a53

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

clojureRS.org

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,34 @@ Perhaps they could look like
160160
'offshoots' of, say, intern in this case (although its basically namespacing
161161
in a way; anytime you're doing something like blah__1 blah__other blah__3,
162162
your blah has become a 'family name' of sorts; a namespace).
163+
** Immutable Data Structures
164+
Right now we likewise use naive immutables; the map is an O(n) associative-list,
165+
meaning its really a list of (key . value) pairs underneath, and a persistent 'history'
166+
is achieved by thinking of the list as a timeline of changes; the first element
167+
is the first change, the second the second, and if you hold the map as it was at this
168+
point in time, you simply point to this second entry. Then, to search for members of the map,
169+
you walk backwards through the timeline -- but not forwards; things will continue to happen, but
170+
they won't affect you because they'll come afterwards.
171+
172+
The persistent vector is just a plain Vec, and more importantly I
173+
don't think there's any structural sharing there atm
174+
175+
The persistent list should be the closest to the proper Clojure structure, and is a Cons list, where
176+
likewise what sublist you reference depends on where your head is pointing to.
177+
178+
The plan is to look into `im` or implement the structures myself, if I find that's necessary. I already
179+
started reverse engineering the PersistentHashMap myself, trying to come up with a structure with the
180+
same time / space complexities, although I will definitely not wait for me to figure that out --
181+
that could take weeks or years or forever -- I'll just look it up. But I'd be neato if I did
182+
** Memory management
183+
Right now, the project uses plain, also-naive reference counting.
184+
Things in the ClojureRS world live inside Rc<Values> , where Value
185+
(again) is an enum wrapping all potential types.
186+
187+
It will be important for this to truly grow, I think, before we start trying to observe it under
188+
the hood, mapping its activities to visuals that show us just
189+
what kind of dance is going on underneath, and where the bottlenecks are.
190+
191+
It will be at that time that it will be best to truly start adding
192+
a deeper design to memory management, although until then I will
193+
keep reading on what others have found before me

0 commit comments

Comments
 (0)