I'm trying to create a collection that plays well with clojure. This is what I came up with:
https://gist.github.com/fctorial/201dc99080528b4e626245a29f342361
I've tried to make it behave like 'PersistentList'. But there's an issue with it. Sometimes an empty collection of this type resolves to '(nil)' when working with it in clojure:
(seq (ROVec. (byte-array 0)))
=> (nil)
(vec (ROVec. (byte-array 0)))
=> []
(vec (seq (ROVec. (byte-array 0))))
=> []
(lazy-seq (ROVec. (byte-array 0)))
=> (nil)
(vec (lazy-seq (ROVec. (byte-array 0))))
=> [nil]
I think the issue is '.first' for an empty ROVec returns nil, just like it does for 'PersistentList'. How do I fix this?