Skip to content

Commit bc604db

Browse files
committed
Merge branch 'feature/use_namespaces'
2 parents 52c980d + 9290a53 commit bc604db

15 files changed

+783
-84
lines changed

clojureRS.org

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,57 @@ Perhaps they could look like
137137

138138
(div 5 0)))
139139
#+END_SRC
140+
** Symbols, Interning
141+
In Clojure proper, there is specific semantics for keywords and symbols -- namely,
142+
#+BEGIN_SRC clojure
143+
(intern "namespace" "name")
144+
145+
(intern "namespace/name")
146+
#+END_SRC
147+
Since Rust doesn't have overloading, we can either do
148+
#+BEGIN_SRC rust
149+
pub fn intern(ns: Option<&str>, name: &str)
150+
#+END_SRC
151+
152+
Or just have two functions. So we've gone with the latter
153+
154+
#+BEGIN_SRC rust
155+
intern(name)
156+
intern_with_ns(ns,name)
157+
#+END_SRC
158+
To be honest, from my time in other languages I've gotten used to
159+
the idea of naming all your functions, giving you all these little
160+
'offshoots' of, say, intern in this case (although its basically namespacing
161+
in a way; anytime you're doing something like blah__1 blah__other blah__3,
162+
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

src/clojure_std.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pub (crate) mod thread;
2-
pub (crate) mod time;
1+
pub(crate) mod thread;
2+
pub(crate) mod time;

0 commit comments

Comments
 (0)