clojure-rs / ClojureRS

Clojure, implemented atop Rust (unofficial)
Apache License 2.0
952 stars 27 forks source link

Cleanup privacy on data structures #61

Open Tko1 opened 4 years ago

Tko1 commented 4 years ago

Structures like PersistentList (and especially ones like PersistentVector, which will internally change) should not have public internals, and should be interacted with through their public interface; we have already had one potential bug where the cached count was used in PersistentList in an impossible scenario (ie, we were matching on the case of PersistentList(_,_,count = 0) , which would actually never happen, as an empty list would be expressed as PersistentList::Empty)

Off top of my head, need to:

  1. Make counting always read with len
  2. Use cons to attached a head to a tail
  3. Convert PersistentVector into Vector explicitly, rather than doing so by cloning its internal vals Vector