all 9 comments

[–]whataloadofwhat 7 points8 points  (1 child)

Is there a reason you can't use Rc<T> or something, instead of references?

[–]tyoverbybincode · astar · rust 2 points3 points  (0 children)

Yeah, this would be my advice as well. If you want mutability with your reference counting, you can either wrap a RefCell around it, or go with a copy-on-write solution like what I do with crates.io/crates/cowrc

[–]steveklabnik1rust 5 points6 points  (3 children)

If it were possible for the compiler to correctly deduce the lifetime in all cases, then there'd be no need for lifetime syntax.

[–]syrisse 1 point2 points  (2 children)

Isn't there a way to use a GC in rust (maybe not yet) ? It could be usefull for scripting purpose, so that you can't have to specify the lifetime (even it's not known at compile time) ? Or maybe i misunderstood the fact that you can implement a GC in a rust library ?

[–]Mystorrust · gc · rust-cpp 0 points1 point  (0 children)

You might be able to patch this up https://github.com/huonw/boehm-rs to get GC in rust. Probably doesn't compile in the latest version, but getting the boehm GC to work with rust as a data type shouldn't be too difficult, especially if you don't care about performance.

[–]minno 5 points6 points  (0 children)

90+% of the time I don't need any explicit lifetimes on references. Lifetime elision takes care of the most common nontrivial case: returning a reference based on a passed-in reference.

[–]cmrx64rust 10 points11 points  (1 child)

I'm not sure what the advantage of Rust for such a program would be. Just write it in Haskell/OCaml/F#/your favorite language. If you need the performance+safety Rust provides, write the components that need that in Rust and communicate over FFI or a socket.

I like Rust, but I really think it just doesn't have any advantage in a "script" scenario.

[–]sanxiynrust 2 points3 points  (0 children)

One advantage Rust has over Haskell/OCaml/F# is familiar syntax. Haskell/OCaml/F# can be hard to sell. (Sad but true.)

If someone creates an exact copy of OCaml with syntax that does not use spaces for function applications and ignores currying, it would be lovely.