Re: [rust-dev] Persistent data structures

2013-12-05 Thread Michael Woerister
On 05.12.2013 03:15, Bill Myers wrote: The reason I introduced COW when RC 1 is that it allows persistent data structures to be mutated in place if there aren't extra references, just like non-persistent data structures. That's a great idea that an might obviate the need to have a separate

Re: [rust-dev] Persistent data structures

2013-12-05 Thread Bill Myers
No, the problem you describe does not exist in my implementation because it requires an mut to the smart pointer. In particular, if the reference count is 1, then there is no other Rc and Arc pointing to the same data, and because we have an mut there is also no other borrowed reference to the

Re: [rust-dev] Persistent data structures

2013-12-05 Thread Michael Woerister
On 05.12.2013 16:59, Bill Myers wrote: No, the problem you describe does not exist in my implementation because it requires an mut to the smart pointer. You are right. I needed some time to wrap my head around this :) This is really a very clever approach! I'm looking forward to experimenting

Re: [rust-dev] Persistent data structures

2013-12-04 Thread Patrick Walton
On 12/3/13 11:28 PM, Isaac Dupree wrote: Is Rc the best smart pointer for persistent data structures? I would think so, for non-thread safe ones. Is it possible for the structure to be parametrized on smart pointer? Not without higher kinded types (which eventually we do want--so the

Re: [rust-dev] Persistent data structures

2013-12-04 Thread Kevin Ballard
On Dec 4, 2013, at 12:23 AM, Patrick Walton pcwal...@mozilla.com wrote: Yes, but I wouldn't worry about this restriction biting users of your structure too much. Rust data structures rarely ever store non-static references in them, as the stack discipline that references must follow is

Re: [rust-dev] Persistent data structures

2013-12-04 Thread Michael Woerister
I've implemented a persistent HAMT [1] a while back: https://github.com/michaelwoerister/rs-persistent-datastructures/blob/master/hamt.rs It's the data structure used for persistent maps in Clojure (and Scala, I think). It's not too hard to implement and it's pretty nifty. I'm not sure about

Re: [rust-dev] Persistent data structures

2013-12-04 Thread Huon Wilson
On 04/12/13 20:51, Michael Woerister wrote: I've implemented a persistent HAMT [1] a while back: https://github.com/michaelwoerister/rs-persistent-datastructures/blob/master/hamt.rs It's the data structure used for persistent maps in Clojure (and Scala, I think). It's not too hard to

Re: [rust-dev] Persistent data structures

2013-12-04 Thread Michael Woerister
For reference, the FromIterator Extendable traits are the things to implement if one has a structure that can be constructed from/extended with an iterator and wishes to share the behaviour. http://static.rust-lang.org/doc/master/std/iter/trait.FromIterator.html

Re: [rust-dev] Persistent data structures

2013-12-04 Thread Niko Matsakis
On Wed, Dec 04, 2013 at 12:23:35AM -0800, Patrick Walton wrote: Not without higher kinded types (which eventually we do want--so the answer is not yet). This. That said, I imagine that if we do it right, it'll be possible to write one persistent map implementation that can be used with GC, ARC,

Re: [rust-dev] Persistent data structures

2013-12-04 Thread Michael Woerister
Is it possible for the structure to be parametrized on smart pointer? Not without higher kinded types (which eventually we do want--so the answer is not yet). I've been thinking about that a bit more and I think it might be possible to support different reference types without higher-kinded

Re: [rust-dev] Persistent data structures

2013-12-04 Thread Bill Myers
Hello, I already implemented a persistent tree-map called SnapMap: you can find the source code at https://github.com/mozilla/rust/pull/9816 I stopped working on it before I made a serious effort to push it into the Rust codebase and don't have time to work further on it, so it would be

Re: [rust-dev] Persistent data structures

2013-12-04 Thread Isaac Dupree
On 12/04/2013 02:09 PM, Michael Woerister wrote: Is it possible for the structure to be parametrized on smart pointer? Not without higher kinded types (which eventually we do want--so the answer is not yet). And then we can define a container type, using the generic reference type: struct

Re: [rust-dev] Persistent data structures

2013-12-04 Thread Daniel Micay
On Wed, Dec 4, 2013 at 4:17 PM, Isaac Dupree m...@isaac.cedarswampstudios.org wrote: On 12/04/2013 02:09 PM, Michael Woerister wrote: Is it possible for the structure to be parametrized on smart pointer? Not without higher kinded types (which eventually we do want--so the answer is not

Re: [rust-dev] Persistent data structures

2013-12-04 Thread Isaac Dupree
On 12/04/2013 03:36 PM, Bill Myers wrote: Hello, I already implemented a persistent tree-map called SnapMap: you can find the source code at https://github.com/mozilla/rust/pull/9816 I stopped working on it before I made a serious effort to push it into the Rust codebase and don't have time to

Re: [rust-dev] Persistent data structures

2013-12-04 Thread Bill Myers
Did COW improve performance? What's a good way to do performance testing of Rust code? The reason I introduced COW when RC 1 is that it allows persistent data structures to be mutated in place if there aren't extra references, just like non-persistent data structures. Lots of languages

Re: [rust-dev] Persistent data structures

2013-12-04 Thread David Piepgrass
My next goal is a persistent tree-map, probably cribbing from Haskell's Data.Map. I look forward to hearing how that goes! I've been meaning to make a data structure in Rust too, but it's hard to find the time, so how's about I tell you guys about it instead. I call my data structure an

Re: [rust-dev] Persistent data structures

2013-12-04 Thread David Piepgrass
Please disregard this message; I hadn't seen Bill Myers' solution (copy-on-write by cloning only when reference count 1), which sounds like it's probably perfect for Rust. On Wed, Dec 4, 2013 at 9:03 PM, David Piepgrass qwertie...@gmail.comwrote: My next goal is a persistent tree-map,

[rust-dev] Persistent data structures

2013-12-03 Thread Isaac Dupree
I'm interested in having persistent data structures[1] in Rust. To start, I implemented the simplest one, the cons/nil list (it looks like extra::list::List has another implementation of it). Am I using Rust conventions properly? My persistent list code:

Re: [rust-dev] Persistent data structures

2013-12-03 Thread Tony Arcieri
On Tue, Dec 3, 2013 at 11:28 PM, Isaac Dupree m...@isaac.cedarswampstudios.org wrote: I'm interested in having persistent data structures[1] in Rust. Nice! -- Tony Arcieri ___ Rust-dev mailing list Rust-dev@mozilla.org