TyOverby / ares

A Lisp made for easy integration with Rust.
9 stars 1 forks source link

What to do about collections? #15

Open TyOverby opened 9 years ago

TyOverby commented 9 years ago

The two main collections are List and Map.

Right now they are backed by Vec and HashMap respectively. Should they be though? We don't have any mutation in them right now, but we could add that really easily. Or should we use persistent data-structures like Clojure?

bwo commented 9 years ago

Are there good persistent maps and array already for Rust? Not having to write them would be a pretty good reason for sticking with Vec and HashMap. (As would ease of interoperation, I suppose.)

TyOverby commented 9 years ago

There are 2 unmaintained implementations of persistent vectors. None for maps though. I don't think that ease of interop will be a problem because right now you have to copy-out anyway.

viperscape commented 9 years ago

I'm quietly following development, but wanted to chime in. If I recall, clojure uses red black trees for persistent vectors, but I don't think this is required because rust provides safety and checks and thus doesn't require a STM. Persistent structures are rather memory intensive as well, I think.

Also, I made a map-like structure which uses vec underneath, maybe this can be of help. example usage of collection type. Interesting to note, it's faster than hashmap.

TyOverby commented 9 years ago

Hah! I have a library just like that! https://github.com/TyOverby/keyed-vec

However, we would not be picking persistent collections for the performance (indeed ares is single-threaded only), but for the functional purity. Having an immutable sequence type in addition to a mutable one would make a lot of sense for a lisp.